summaryrefslogtreecommitdiff
path: root/adodb.inc.php
diff options
context:
space:
mode:
authorMike Benoit <mikeb@timetrex.com>2015-03-12 15:23:30 -0700
committerDamien Regad <dregad@mantisbt.org>2015-04-20 14:32:31 +0200
commit41839f5c18abe262ee088f1d4bd92453616d2a4a (patch)
tree9f23b2aacb8372dba6b4548195e8103a039944bf /adodb.inc.php
parent88f185532a2587cf7f0b9b3d0cfa33ddc9c8cc50 (diff)
downloadadodb-41839f5c18abe262ee088f1d4bd92453616d2a4a.tar.gz
adodb-41839f5c18abe262ee088f1d4bd92453616d2a4a.tar.bz2
adodb-41839f5c18abe262ee088f1d4bd92453616d2a4a.zip
Add support for pagination with complex queries
There are cases where ADODB is not be able to figure out the proper count(*) queries for PageExecute() on its own. To work around this problem, ADOdb now handles a new keyword "_ADODB_COUNT" that can be wrapped around the parts of the SQL query that should be replaced with "COUNT(*)"; the code will remove everything between and including the _ADODB_COUNT keywords and replace it with COUNT(*). The _ADODB_COUNT tags are of course removed when COUNT(*) is not needed. Example usage: SELECT _ADODB_COUNT col1, col2, col3, ( select col4 from table2 where col1=col2 ) col4, _ADODB_COUNT FROM table1 LEFT JOIN ( select col5 from table3 where col3=col4 ) AS tmp; Original 2012 bug report: http://phplens.com/lens/lensforum/msgs.php?id=19058 The fix has been in use since that time in hundreds of thousands of production installations. Fixes #88 Signed-off-by: Damien Regad <dregad@mantisbt.org>
Diffstat (limited to 'adodb.inc.php')
-rw-r--r--adodb.inc.php5
1 files changed, 5 insertions, 0 deletions
diff --git a/adodb.inc.php b/adodb.inc.php
index d5dd29ac..c4ccc4a2 100644
--- a/adodb.inc.php
+++ b/adodb.inc.php
@@ -1122,8 +1122,13 @@ if (!defined('_ADODB_LAYER')) {
return $ret;
}
+ //Strips keyword used to help generate SELECT COUNT(*) queries from SQL if it exists.
+ function adodb_strip_count_keyword( $sql ) {
+ return ADODB_str_replace( '_ADODB_COUNT', '', $sql );
+ }
function _Execute($sql,$inputarr=false) {
+ $sql = $this->adodb_strip_count_keyword( $sql );
if ($this->debug) {
global $ADODB_INCLUDED_LIB;
if (empty($ADODB_INCLUDED_LIB)) {