From 2e6fa44aa21c1e9dec4dbe4d16656cf0de4a23da Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 29 Mar 2016 14:55:38 -0700 Subject: [PATCH] Fix for SQL_CALC_FOUND_ROWS using PDO. --- e107_handlers/e107_class.php | 42 +++++++++++++---------------- e107_handlers/mysql_class.php | 20 +++++++++----- e107_handlers/shortcode_handler.php | 2 +- userposts.php | 2 +- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index ac56dee2a..7644bb853 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1870,29 +1870,25 @@ class e107 * @param null $var * @param string $type */ - public static function debug($name, $var = null, $type = 'log', $js = false) + public static function debug($name, $var = null, $type = 'log') { $nl = "\r\n"; // echo "alert('hi');"; - - if($js != true) - { - echo ''.$nl; - } + + e107::js('footer-inline', $text); } diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index b6442f0ac..ce474532e 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -495,17 +495,23 @@ class e_db_mysql $db_time += $mytime; $this->mySQLresult = $sQryRes; - $this->total_results = false; + if (!E107_DEBUG_LEVEL) + { + $this->total_results = false; + } // Need to get the total record count as well. Return code is a resource identifier // Have to do this before any debug action, otherwise this bit gets messed up - if (!is_array($query) && (strpos($query,'SQL_CALC_FOUND_ROWS') !== false) && (strpos($query,'SELECT') !== false)) + + + + if (!is_array($query) && (strpos($query,'EXPLAIN') !==0) && (strpos($query,'SQL_CALC_FOUND_ROWS') !== false) && (strpos($query,'SELECT') !== false)) { + if($this->pdo) { - $fr = $this->mySQLaccess->query('SELECT FOUND_ROWS()'); - $rc = $fr->fetchColumn(); - $this->total_results = (int) $rc; + $rc = $this->mySQLaccess->query('SELECT FOUND_ROWS();')->fetch(PDO::FETCH_COLUMN); + $this->total_results = intval($rc); } else /* @XXX Subject of Removal. */ { @@ -925,10 +931,10 @@ class e_db_mysql /** - * Return the total number of results on the last query regardless of the LIMIT value. + * Return the total number of results on the last query regardless of the LIMIT value when SELECT SQL_CALC_FOUND_ROWS is used. * @return bool */ - public function totalResults() + public function foundRows() { return $this->total_results; } diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index fb9ba3f63..3e75ff235 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -409,7 +409,7 @@ class e_parse_shortcode } elseif(E107_DBG_BBSC || E107_DBG_SC) { - echo "

Couldn't Load: ".$path." with class-name: {$className} and pluginName {$pluginName}

"; + echo "
Couldn't Load: ".$path." with class-name: {$className} and pluginName {$pluginName}
"; } diff --git a/userposts.php b/userposts.php index 4e3cdefe3..7ec0c2f09 100644 --- a/userposts.php +++ b/userposts.php @@ -239,7 +239,7 @@ elseif ($action == 'forums') $vars->emptyVars(); - $ftotal = $sqlp->totalResults(); + $ftotal = $sqlp->foundRows(); $parms = $ftotal.",10,".$from.",".e_REQUEST_SELF."?[FROM].forums.".$id; $vars->NEXTPREV = $ftotal ? $tp->parseTemplate("{NEXTPREV={$parms}}") : '';