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

@ -62,6 +62,10 @@
gain, but it was already really fast, so relatively users aren't likely to
notice the difference. However, this change helps in the overall
scalability of WebGUI under load.
- Added the ability to use replicated slave databases to lessen the load on
the master database. This will have no effect on single database users, but
can add a tremendous amount of scalability on large WebGUI sites that use
database replication.
6.0.3

View file

@ -68,8 +68,7 @@ sub _processFunctions {
if ($session{form}{wid} eq "new") {
$wobject = {wobjectId=>"new",namespace=>$session{form}{namespace},pageId=>$session{page}{pageId}};
} else {
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobjectId="
.$session{form}{wid});
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobjectId=".$session{form}{wid},WebGUI::SQL->getSlave);
if (${$wobject}{namespace} eq "") {
WebGUI::ErrorHandler::warn("Wobject [$session{form}{wid}] appears to be missing or "
."corrupt, but was requested "
@ -83,7 +82,7 @@ sub _processFunctions {
wobject,WobjectProxy
where wobject.wobjectId=WobjectProxy.wobjectId
and wobject.pageId=".$session{page}{pageId}."
and WobjectProxy.proxiedWobjectId=".${$wobject}{wobjectId});
and WobjectProxy.proxiedWobjectId=".${$wobject}{wobjectId},WebGUI::SQL->getSlave);
${$wobject}{_WobjectProxy} = $proxyWobjectId;
}
unless (${$wobject}{pageId} == $session{page}{pageId}

View file

@ -184,7 +184,7 @@ sub getReplies {
$query .= "(status='approved'";
}
$query .= " or userId=$session{user}{userId}) order by forumPostId";
my $sth = WebGUI::SQL->read($query);
my $sth = WebGUI::SQL->read($query,WebGUI::SQL->getSlave);
while (my @data = $sth->array) {
push(@replies,WebGUI::Forum::Post->new($data[0]));
}

View file

@ -172,7 +172,7 @@ sub getNextThread {
my ($self) = @_;
unless (exists $self->{_next}) {
my ($nextId) = WebGUI::SQL->quickArray("select min(forumThreadId) from forumThread where forumId=".$self->get("forumId")."
and forumThreadId>".$self->get("forumThreadId"));
and forumThreadId>".$self->get("forumThreadId"),WebGUI::SQL->getSlave);
$self->{_next} = WebGUI::Forum::Thread->new($nextId);
}
return $self->{_next};
@ -214,7 +214,7 @@ sub getPreviousThread {
my ($self) = @_;
unless (exists $self->{_previous}) {
my ($nextId) = WebGUI::SQL->quickArray("select max(forumThreadId) from forumThread where forumId=".$self->get("forumId")."
and forumThreadId<".$self->get("forumThreadId"));
and forumThreadId<".$self->get("forumThreadId"),WebGUI::SQL->getSlave);
$self->{_previous} = WebGUI::Forum::Thread->new($nextId);
}
return $self->{_previous};

View file

@ -198,7 +198,7 @@ sub processReplacements {
$content =~ s/\Q$searchFor/$replaceWith/gs;
}
} else {
my $sth = WebGUI::SQL->read("select searchFor,replaceWith from replacements");
my $sth = WebGUI::SQL->read("select searchFor,replaceWith from replacements",WebGUI::SQL->getSlave);
while (my ($searchFor,$replaceWith) = $sth->array) {
$session{replacements}{$searchFor} = $replaceWith;
$content =~ s/\Q$searchFor/$replaceWith/gs;

View file

@ -19,7 +19,7 @@ use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my @param = WebGUI::Macro::getParams($_[0]);
my ($groupId) = WebGUI::SQL->quickArray("select groupId from groups where groupName=".quote($param[0]));
my ($groupId) = WebGUI::SQL->quickArray("select groupId from groups where groupName=".quote($param[0]),WebGUI::SQL->getSlave);
$groupId = 3 if ($groupId eq "");
if (WebGUI::Grouping::isInGroup($groupId)) {
return $param[1];

View file

@ -23,7 +23,7 @@ sub process {
if ($session{setting}{defaultPage} == $session{page}{pageId}) {
$temp = $session{page}{urlizedTitle};
} else {
($temp) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=$session{setting}{defaultPage}");
($temp) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=$session{setting}{defaultPage}",WebGUI::SQL->getSlave);
}
$temp = WebGUI::URL::gateway($temp);
if ($param[0] ne "linkonly") {

View file

@ -24,7 +24,7 @@ sub process {
$format = '%z' if ($format eq "");
$output = "";
($time) = WebGUI::SQL->quickArray("SELECT max(lastEdited) FROM wobject where pageId=$session{page}{pageId}");
($time) = WebGUI::SQL->quickArray("SELECT max(lastEdited) FROM wobject where pageId=$session{page}{pageId}",WebGUI::SQL->getSlave);
if ($time) {
$output = $label.epochToHuman($time,$format);
}

View file

@ -23,11 +23,11 @@ sub process {
my $collateralFolderId = 0;
if ($param[0] ne "") {
($collateralFolderId) = WebGUI::SQL->quickArray("select collateralFolderId from collateralFolder
where name=".quote($param[0]));
where name=".quote($param[0]),WebGUI::SQL->getSlave);
$collateralFolderId = 0 unless ($collateralFolderId);
}
my @images = WebGUI::SQL->buildArray("select collateralId from collateral
where collateralType='image' and collateralFolderId=".$collateralFolderId);
where collateralType='image' and collateralFolderId=".$collateralFolderId,WebGUI::SQL->getSlave);
if (my $collateral = WebGUI::Collateral->new($images[rand($#images+1)])) {
return '<img src="'.$collateral->getURL.'" '.$collateral->get("parameters").' />';
} else {

View file

@ -23,11 +23,11 @@ sub process {
my $collateralFolderId = 0;
if ($param[0] ne "") {
($collateralFolderId) = WebGUI::SQL->quickArray("select collateralFolderId from collateralFolder
where name=".quote($param[0]));
where name=".quote($param[0]),WebGUI::SQL->getSlave);
$collateralFolderId = 0 unless ($collateralFolderId);
}
my @snippets = WebGUI::SQL->buildArray("select collateralId from collateral
where collateralType='snippet' and collateralFolderId=".$collateralFolderId);
where collateralType='snippet' and collateralFolderId=".$collateralFolderId,WebGUI::SQL->getSlave);
if (my $collateral = WebGUI::Collateral->new($snippets[rand($#snippets+1)])) {
return $collateral->get("parameters");
} else {

View file

@ -21,7 +21,7 @@ use WebGUI::URL;
sub process {
my ($sth, %data, $output);
tie %data, 'Tie::CPHash';
%data = WebGUI::SQL->quickHash("select pageId,parentId,title,urlizedTitle from page where pageId=".($_[0] || $session{page}{parentId}));
%data = WebGUI::SQL->quickHash("select pageId,parentId,title,urlizedTitle from page where pageId=".($_[0] || $session{page}{parentId}),WebGUI::SQL->getSlave);
if ($data{parentId} == 0) {
$output = $data{title} || $session{page}{title};
} else {

View file

@ -21,7 +21,7 @@ sub process {
my ($statement, $format) = WebGUI::Macro::getParams(shift);
$format = '^0;' if ($format eq "");
if ($statement =~ /^\s*select/i || $statement =~ /^\s*show/i || $statement =~ /^\s*describe/i) {
my $sth = WebGUI::SQL->unconditionalRead($statement);
my $sth = WebGUI::SQL->unconditionalRead($statement,WebGUI::SQL->getSlave);
unless ($sth->errorCode < 1) {
return '<p><b>SQL Macro Failed:</b> '.$sth->errorMessage.'<p>';
} else {

View file

@ -28,7 +28,7 @@ sub process {
}
$temp = WebGUI::URL::append($session{env}{REQUEST_URI},$append);
if ($param[1] ne "") {
($styleId) = WebGUI::SQL->quickArray("select styleId from style where name=".quote($param[1]));
($styleId) = WebGUI::SQL->quickArray("select styleId from style where name=".quote($param[1]),WebGUI::SQL->getSlave);
if ($styleId != 0) {
$temp = WebGUI::URL::append($temp,'styleId='.$styleId);
}

View file

@ -41,7 +41,7 @@ sub getRequiredProfileFields {
#$f = WebGUI::HTMLForm->new();
$a = WebGUI::SQL->read("select * from userProfileField, userProfileCategory where userProfileField.profileCategoryId=userProfileCategory.profileCategoryId and
userProfileField.required=1 order by userProfileCategory.sequenceNumber,userProfileField.sequenceNumber");
userProfileField.required=1 order by userProfileCategory.sequenceNumber,userProfileField.sequenceNumber",WebGUI::SQL->getSlave);
while($data = $a->hashRef) {
my %hash = ();
$method = $data->{dataType};
@ -225,7 +225,8 @@ sub www_viewProfile {
return $vars->{displayTitle}.WebGUI::International::get(862) if($u->profileField("publicProfile") < 1);
return WebGUI::Privilege::insufficient() if(!WebGUI::Grouping::isInGroup(2));
$a = WebGUI::SQL->read("select * from userProfileField,userProfileCategory where userProfileField.profileCategoryId=userProfileCategory.profileCategoryId
and userProfileCategory.visible=1 and userProfileField.visible=1 order by userProfileCategory.sequenceNumber,userProfileField.sequenceNumber");
and userProfileCategory.visible=1 and userProfileField.visible=1 order by userProfileCategory.sequenceNumber,
userProfileField.sequenceNumber",WebGUI::SQL->getSlave);
while (%data = $a->hash) {
$category = eval $data{categoryName};
if ($category ne $previousCategory) {

View file

@ -223,7 +223,7 @@ sub canView {
if ($pageId eq $session{page}{pageId}) {
%page = %{$session{page}};
} else {
%page = WebGUI::SQL->quickHash("select ownerId,groupIdView,startDate,endDate from page where pageId=$pageId");
%page = WebGUI::SQL->quickHash("select ownerId,groupIdView,startDate,endDate from page where pageId=$pageId",WebGUI::SQL->getSlave);
}
if ($session{user}{userId} == $page{ownerId}) {
return 1;
@ -404,7 +404,7 @@ sub generate {
.moveUpIcon('op=movePageUp')
.moveDownIcon('op=movePageDown')
.cutIcon('op=cutPage');
my $sth = WebGUI::SQL->read("select * from wobject where pageId=".$session{page}{pageId}." order by sequenceNumber, wobjectId");
my $sth = WebGUI::SQL->read("select * from wobject where pageId=".$session{page}{pageId}." order by sequenceNumber, wobjectId",WebGUI::SQL->getSlave);
while (my $wobject = $sth->hashRef) {
my $wobjectToolbar = wobjectIcon()
.deleteIcon('func=delete&wid='.${$wobject}{wobjectId})
@ -420,8 +420,8 @@ sub generate {
}
if (${$wobject}{namespace} eq "WobjectProxy") {
my $originalWobject = $wobject;
my ($wobjectProxy) = WebGUI::SQL->quickHashRef("select * from WobjectProxy where wobjectId=".${$wobject}{wobjectId});
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobject.wobjectId=".$wobjectProxy->{proxiedWobjectId});
my ($wobjectProxy) = WebGUI::SQL->quickHashRef("select * from WobjectProxy where wobjectId=".${$wobject}{wobjectId},WebGUI::SQL->getSlave);
$wobject = WebGUI::SQL->quickHashRef("select * from wobject where wobject.wobjectId=".$wobjectProxy->{proxiedWobjectId},WebGUI::SQL->getSlave);
if (${$wobject}{namespace} eq "") {
$wobject = $originalWobject;
} else {

View file

@ -513,7 +513,7 @@ A boolean indicating that the query should be read unconditionally. Defaults to
sub setDataByQuery {
my ($sth, $rowCount, @row);
my ($self, $sql, $dbh, $unconditional) = @_;
$dbh ||= $session{dbh};
$dbh ||= WebGUI::SQL->getSlave;
if ($unconditional) {
$sth = WebGUI::SQL->unconditionalRead($sql,$dbh);
return $sth->errorMessage if ($sth->errorCode > 0);

View file

@ -65,6 +65,8 @@ Package for interfacing with SQL databases. This package implements Perl DBI fun
$hashRef = WebGUI::SQL->quickHashRef($sql);
$text = WebGUI::SQL->quickTab($sql);
$dbh = WebGUI::SQL->getSlave;
$id = getNextId("wobjectId");
$string = quote($string);
@ -75,6 +77,12 @@ These methods are available from this package:
=cut
#-------------------------------------------------------------------
sub _getDefaultDb {
return $WebGUI::Session::session{dbh};
}
#-------------------------------------------------------------------
=head2 array ( )
@ -387,6 +395,25 @@ sub getRow {
return $row;
}
#-------------------------------------------------------------------
=head2 getSlave ( )
Returns a random slave database handler, if one is defined, otherwise it returns undef. Likewise if admin mode is on it returns undef.
=cut
sub getSlave {
if ($WebGUI::Session::session{var}{adminOn}) {
return undef;
} else {
return $WebGUI::Session::session{slave}->[rand @{$WebGUI::Session::session{slave}}];
}
}
#-------------------------------------------------------------------
=head2 hash ( )
@ -450,7 +477,7 @@ A database handler. Defaults to the WebGUI default database handler.
sub prepare {
my $class = shift;
my $sql = shift;
my $dbh = shift || $WebGUI::Session::session{dbh};
my $dbh = shift || _getDefaultDb();
if ($WebGUI::Session::session{setting}{showDebug}) {
push(@{$WebGUI::Session::session{SQLquery}},$sql);
}
@ -622,7 +649,7 @@ sub quickTab {
#-------------------------------------------------------------------
=head2 quote ( string )
=head2 quote ( string [ , dbh ] )
Returns a string quoted and ready for insert into the database.
@ -634,13 +661,18 @@ NOTE: This is not a regular method, but is an exported subroutine.
Any scalar variable that needs to be escaped to be inserted into the database.
=item dbh
The database handler. Defaults to the WebGUI database handler.
=back
=cut
sub quote {
my $value = $_[0]; #had to add this here cuz Tie::CPHash variables cause problems otherwise.
return $WebGUI::Session::session{dbh}->quote($value);
my $value = shift; #had to add this here cuz Tie::CPHash variables cause problems otherwise.
my $dbh = shift || _getDefaultDb();
return $dbh->quote($value);
}
@ -780,7 +812,7 @@ By default this method uses the WebGUI database handler. However, you may choose
sub unconditionalRead {
my $class = shift;
my $sql = shift;
my $dbh = shift || $WebGUI::Session::session{dbh};
my $dbh = shift || _getDefaultDb();
if ($WebGUI::Session::session{setting}{showDebug}) {
push(@{$WebGUI::Session::session{SQLquery}},$sql);
}
@ -815,7 +847,7 @@ By default this method uses the WebGUI database handler. However, you may choose
sub write {
my $class = shift;
my $sql = shift;
my $dbh = shift || $WebGUI::Session::session{dbh};
my $dbh = shift || _getDefaultDb();
if ($WebGUI::Session::session{setting}{showDebug}) {
push(@{$WebGUI::Session::session{SQLquery}},$sql);
}

View file

@ -314,6 +314,11 @@ sub open {
$session{dbh}->{LongReadLen} = 512 * 1024;
$session{dbh}->{LongTruncOk} = 1;
}
foreach (1..3) {
if ($session{config}{"dbslave".$_}) {
push(@{$session{slave}},DBI->connect($session{config}{"dbslave".$_}{dsn},$session{config}{"dbslave".$_}{user},$session{config}{"dbslave".$_}{pass}));
}
}
###----------------------------
### global system settings (from settings table)
$session{setting} = WebGUI::SQL->buildHashRef("select name,value from settings");

View file

@ -19,7 +19,6 @@ use strict;
use Tie::CPHash;
use WebGUI::International;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Template;

View file

@ -108,7 +108,7 @@ Defaults to "page". Specify the namespace of the template to retrieve.
sub get {
my $templateId = shift || 1;
my $namespace = shift || "page";
return WebGUI::SQL->quickHashRef("select * from template where templateId=".$templateId." and namespace=".quote($namespace));
return WebGUI::SQL->quickHashRef("select * from template where templateId=".$templateId." and namespace=".quote($namespace),WebGUI::SQL->getSlave);
}
@ -130,7 +130,7 @@ Defaults to "page". Specify the namespace to build the list for.
sub getList {
my $namespace = $_[0] || "page";
return WebGUI::SQL->buildHashRef("select templateId,name from template where namespace=".quote($namespace)." and showInForms=1 order by name");
return WebGUI::SQL->buildHashRef("select templateId,name from template where namespace=".quote($namespace)." and showInForms=1 order by name",WebGUI::SQL->getSlave);
}
@ -184,7 +184,7 @@ sub process {
$params{double_file_cache} = 1;
}
unless (-f $file->getPath) {
my ($template) = WebGUI::SQL->quickArray("select template from template where templateId=".$templateId." and namespace=".quote($namespace));
my ($template) = WebGUI::SQL->quickArray("select template from template where templateId=".$templateId." and namespace=".quote($namespace),WebGUI::SQL->getSlave);
$file->saveFromScalar($template);
}
return _execute(\%params,$vars);

View file

@ -347,7 +347,7 @@ sub getCollateral {
if ($keyValue eq "new" || $keyValue eq "") {
return {$keyName=>"new"};
} else {
return WebGUI::SQL->quickHashRef("select * from $tableName where $keyName=".quote($keyValue));
return WebGUI::SQL->quickHashRef("select * from $tableName where $keyName=".quote($keyValue),WebGUI::SQL->getSlave);
}
}
@ -766,7 +766,7 @@ sub new {
my %fullProperties;
my $extra;
unless ($properties->{wobjectId} eq "new") {
$extra = WebGUI::SQL->quickHashRef("select * from ".$properties->{namespace}." where wobjectId='".$properties->{wobjectId}."'");
$extra = WebGUI::SQL->quickHashRef("select * from ".$properties->{namespace}." where wobjectId='".$properties->{wobjectId}."'",WebGUI::SQL->getSlave);
}
tie %fullProperties, 'Tie::CPHash';
%fullProperties = (%{$properties},%{$extra});
@ -838,7 +838,7 @@ sub processTemplate {
);
if (defined $self->get("_WobjectProxy")) {
$vars{isShortcut} = 1;
my ($originalPageURL) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=".$self->get("pageId"));
my ($originalPageURL) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=".$self->get("pageId"),WebGUI::SQL->getSlave);
$vars{originalURL} = WebGUI::URL::gateway($originalPageURL."#".$self->get("wobjectId"));
}
my $namespace = $namespace || $self->get("namespace");

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"));