From 37367a6c9f5f923042d18457f10d7f7469299837 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 5 Oct 2007 14:46:48 +0000 Subject: [PATCH] SQL Reports were broken in non-mysql --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/DatabaseLink.pm | 17 +++++++++++++++++ lib/WebGUI/Paginator.pm | 8 ++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 18ce5df88..e9ad4ffe2 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -10,6 +10,7 @@ - Collaboration systems should always tell browser there is new content - fix: Good Bad fields not properly localized - fix: File user profile fields didn't link to the file + - fix: SQL Reports only work on MySQL databases 7.4.8 - fix: Syndicated Content doesn't display all items with multiple feeds in interleaved mode diff --git a/lib/WebGUI/DatabaseLink.pm b/lib/WebGUI/DatabaseLink.pm index 32ab90c1d..ce200e259 100644 --- a/lib/WebGUI/DatabaseLink.pm +++ b/lib/WebGUI/DatabaseLink.pm @@ -266,6 +266,23 @@ sub get { #------------------------------------------------------------------- +=head2 getDriver ( ) + +Returns the DBI driver used by this database link + +=cut + +sub getDriver { + my $self = shift; + my $dsn = $self->get->{DNS}; + if ($dsn =~ /^dbi:(\w+):/i) { + return $1; + } + return; +} + +#------------------------------------------------------------------- + =head2 getId ( ) Returns the ID of this database link. diff --git a/lib/WebGUI/Paginator.pm b/lib/WebGUI/Paginator.pm index 079ccc2a8..36636b3cb 100644 --- a/lib/WebGUI/Paginator.pm +++ b/lib/WebGUI/Paginator.pm @@ -680,12 +680,12 @@ sub setDataByQuery { my $pageNumber = $self->getPageNumber; my $rowsPerPage = $self->{_rpp}; - #Handle dynamicPageNumber requests or custom limts the old way as it winds up being most efficient - if ((defined $dynamicPageNumberKey && $pageNumber == 1) || $sql =~ m/limit/i) { + $dbh ||= $self->session->dbSlave; + + #Handle dynamicPageNumber requests or custom limits, or non-mysql the old way as it winds up being most efficient + if ($dbh->getDriver ne 'mysql' || (defined $dynamicPageNumberKey && $pageNumber == 1) || $sql =~ m/limit/i) { return $self->_setDataByQuery(@_); } - - $dbh ||= $self->session->dbSlave; #Calculate where to start my $start = ( ($pageNumber - 1) * $rowsPerPage );