added support for reading from replicated databases

This commit is contained in:
JT Smith 2004-07-09 21:10:58 +00:00
parent c39e7dc7b0
commit 7648c6c13f
24 changed files with 87 additions and 48 deletions

View file

@ -23,7 +23,6 @@ use WebGUI::International;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Wobject;

View file

@ -371,7 +371,7 @@ sub www_view {
if ($_[0]->get("startMonth") eq "first") {
my $query = "select min(startDate) from EventsCalendar_event";
$query .= " where wobjectId=".$_[0]->get("wobjectId") unless ($_[0]->get("isMaster"));
($minDate) = WebGUI::SQL->quickArray($query);
($minDate) = WebGUI::SQL->quickArray($query,WebGUI::SQL->getSlave);
} elsif ($_[0]->get("startMonth") eq "january") {
$minDate = WebGUI::DateTime::humanToEpoch(WebGUI::DateTime::epochToHuman("","%y")."-01-01 00:00:00");
} else {
@ -383,7 +383,7 @@ sub www_view {
if ($_[0]->get("endMonth") eq "last") {
my $query = "select max(endDate) from EventsCalendar_event";
$query .= " where wobjectId=".$_[0]->get("wobjectId") unless ($_[0]->get("isMaster"));
($maxDate) = WebGUI::SQL->quickArray($query);
($maxDate) = WebGUI::SQL->quickArray($query,WebGUI::SQL->getSlave);
} elsif ($_[0]->get("endMonth") eq "after12") {
$maxDate = WebGUI::DateTime::addToDate($minDate,1,0,0);
} elsif ($_[0]->get("endMonth") eq "after9") {
@ -423,7 +423,7 @@ sub www_view {
$query .= " (endDate>=$monthStart and endDate<=$monthEnd) and (startDate>=$monthStart and startDate<=$monthEnd) order by startDate,endDate";
my %events;
my %previous;
my $sth = WebGUI::SQL->read($query);
my $sth = WebGUI::SQL->read($query,WebGUI::SQL->getSlave);
while (my $event = $sth->hashRef) {
my $eventLength = WebGUI::DateTime::getDaysInInterval($event->{startDate},$event->{endDate});
my $startYear = epochToHuman($event->{startDate},"%y");
@ -539,7 +539,7 @@ sub www_view {
sub www_viewEvent {
my ($output, %event, %var, $id);
tie %event, 'Tie::CPHash';
%event = WebGUI::SQL->quickHash("select * from EventsCalendar_event where EventsCalendar_eventId=$session{form}{eid}");
%event = WebGUI::SQL->quickHash("select * from EventsCalendar_event where EventsCalendar_eventId=$session{form}{eid}",WebGUI::SQL->getSlave);
$var{title} = $event{name};
$var{"start.label"} = WebGUI::International::get(14,$_[0]->get("namespace"));
$var{"start.date"} = epochToHuman($event{startDate},"%z");
@ -556,13 +556,13 @@ sub www_viewEvent {
my $query = "select EventsCalendar_eventId from EventsCalendar_event where EventsCalendar_eventId<>$event{EventsCalendar_eventId}";
$query .= " and wobjectId=".$_[0]->get("wobjectId") unless ($_[0]->get("isMaster"));
$query .= " and startDate<=$event{startDate} order by startDate desc, endDate desc";
($id) = WebGUI::SQL->quickArray($query);
($id) = WebGUI::SQL->quickArray($query,WebGUI::SQL->getSlave);
$var{"previous.label"} = '&laquo;'.WebGUI::International::get(92,$_[0]->get("namespace"));
$var{"previous.url"} = WebGUI::URL::page("func=viewEvent&wid=".$_[0]->get("wobjectId")."&eid=".$id) if ($id);
$query = "select EventsCalendar_eventId from EventsCalendar_event where EventsCalendar_eventId<>$event{EventsCalendar_eventId}";
$query .= " and wobjectId=".$_[0]->get("wobjectId") unless ($_[0]->get("isMaster"));
$query .= " and startDate>=$event{startDate} order by startDate, endDate";
($id) = WebGUI::SQL->quickArray($query);
($id) = WebGUI::SQL->quickArray($query,WebGUI::SQL->getSlave);
$var{"next.label"} = WebGUI::International::get(93,$_[0]->get("namespace")).'&raquo;';
$var{"next.url"} = WebGUI::URL::page("func=viewEvent&wid=".$_[0]->get("wobjectId")."&eid=".$id) if ($id);
$var{description} = $event{description};

View file

@ -696,7 +696,7 @@ sub www_view {
$imageURL = "";
}
($responses) = WebGUI::SQL->quickArray("select count(*) from forumPost left join forumThread on
forumThread.forumThreadId=forumPost.forumThreadId where forumThread.forumId=".$row->{forumId});
forumThread.forumThreadId=forumPost.forumThreadId where forumThread.forumId=".$row->{forumId},WebGUI::SQL->getSlave);
my $quickurl = 'wid='.$_[0]->get("wobjectId").'&amp;sid='.$page->[$i]->{USS_submissionId}.'&amp;func=';
my $controls = deleteIcon($quickurl.'deleteSubmission')
.editIcon($quickurl.'editSubmission');
@ -767,7 +767,7 @@ sub www_viewRSS {
("select USS_submissionId, content, title, " .
"dateSubmitted, username from USS_submission " .
"where USS_id = " .$session{dbh}->quote($_[0]->get("USS_id")) . " and status='Approved' " .
"order by ".$_[0]->getValue("sortBy")." ".$_[0]->getValue("sortOrder")." limit " . $numResults);
"order by ".$_[0]->getValue("sortBy")." ".$_[0]->getValue("sortOrder")." limit " . $numResults,WebGUI::SQL->getSlave);
while (my $row = $res->{_sth}->fetchrow_arrayref()) {
my ($sid, $content, $title, $dateSubmitted, $username) =
@ -841,13 +841,13 @@ sub www_viewSubmission {
$var{"post.label"} = WebGUI::International::get(20,$_[0]->get("namespace"));
@data = WebGUI::SQL->quickArray("select max(USS_submissionId) from USS_submission
where USS_id=".$_[0]->get("USS_id")." and USS_submissionId<$submission->{USS_submissionId}
and (userId=$submission->{userId} or status='Approved')");
and (userId=$submission->{userId} or status='Approved')",WebGUI::SQL->getSlave);
$var{"previous.more"} = ($data[0] ne "");
$var{"previous.url"} = WebGUI::URL::page('func=viewSubmission&sid='.$data[0].'&wid='.$session{form}{wid});
$var{"previous.label"} = WebGUI::International::get(58,$_[0]->get("namespace"));
@data = WebGUI::SQL->quickArray("select min(USS_submissionId) from USS_submission
where USS_id=$submission->{USS_id} and USS_submissionId>$submission->{USS_submissionId}
and (userId=$submission->{userId} or status='Approved')");
and (userId=$submission->{userId} or status='Approved')",WebGUI::SQL->getSlave);
$var{"next.more"} = ($data[0] ne "");
$var{"next.url"} = WebGUI::URL::page('func=viewSubmission&sid='.$data[0].'&wid='.$session{form}{wid});
$var{"next.label"} = WebGUI::International::get(59,$_[0]->get("namespace"));