mirror of
https://github.com/e107inc/e107.git
synced 2025-07-29 10:50:25 +02:00
Fix for SQL_CALC_FOUND_ROWS using PDO.
This commit is contained in:
@@ -1870,29 +1870,25 @@ class e107
|
|||||||
* @param null $var
|
* @param null $var
|
||||||
* @param string $type
|
* @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";
|
$nl = "\r\n";
|
||||||
// echo "alert('hi');";
|
// echo "alert('hi');";
|
||||||
|
$text = '';
|
||||||
if($js != true)
|
|
||||||
{
|
|
||||||
echo '<script type="text/javascript">'.$nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch($type) {
|
switch($type) {
|
||||||
case 'log':
|
case 'log':
|
||||||
echo 'console.log("'.$name.'");'.$nl;
|
$text .= 'console.log("'.$name.'");'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'info':
|
case 'info':
|
||||||
echo 'console.info("'.$name.'");'.$nl;
|
$text .= 'console.info("'.$name.'");'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'warning':
|
case 'warning':
|
||||||
echo 'console.warn("'.$name.'");'.$nl;
|
$text .= 'console.warn("'.$name.'");'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
echo 'console.error("'.$name.'");'.$nl;
|
$text .= 'console.error("'.$name.'");'.$nl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1902,22 +1898,22 @@ class e107
|
|||||||
{
|
{
|
||||||
$object = json_encode($var);
|
$object = json_encode($var);
|
||||||
|
|
||||||
echo 'var object'.preg_replace('~[^A-Z|0-9]~i',"_",$name).' = \''.str_replace("'","\'",$object).'\';'.$nl;
|
$text .= 'var object'.preg_replace('~[^A-Z|0-9]~i',"_",$name).' = \''.str_replace("'","\'",$object).'\';'.$nl;
|
||||||
echo 'var val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).' = eval("(" + object'.preg_replace('~[^A-Z|0-9]~i',"_",$name).' + ")" );'.$nl;
|
$text .= 'var val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).' = eval("(" + object'.preg_replace('~[^A-Z|0-9]~i',"_",$name).' + ")" );'.$nl;
|
||||||
|
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case 'log':
|
case 'log':
|
||||||
echo 'console.debug(val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).');'.$nl;
|
$text .= 'console.debug(val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).');'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'info':
|
case 'info':
|
||||||
echo 'console.info(val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).');'.$nl;
|
$text .= 'console.info(val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).');'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'warning':
|
case 'warning':
|
||||||
echo 'console.warn(val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).');'.$nl;
|
$text .= 'console.warn(val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).');'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
echo 'console.error(val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).');'.$nl;
|
$text .= 'console.error(val'.preg_replace('~[^A-Z|0-9]~i',"_",$name).');'.$nl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1926,25 +1922,23 @@ class e107
|
|||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case 'log':
|
case 'log':
|
||||||
echo 'console.debug("'.str_replace('"','\\"',$var).'");'.$nl;
|
$text .= 'console.debug("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'info':
|
case 'info':
|
||||||
echo 'console.info("'.str_replace('"','\\"',$var).'");'.$nl;
|
$text .= 'console.info("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'warning':
|
case 'warning':
|
||||||
echo 'console.warn("'.str_replace('"','\\"',$var).'");'.$nl;
|
$text .= 'console.warn("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||||
break;
|
break;
|
||||||
case 'error':
|
case 'error':
|
||||||
echo 'console.error("'.str_replace('"','\\"',$var).'");'.$nl;
|
$text .= 'console.error("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($js != true)
|
|
||||||
{
|
e107::js('footer-inline', $text);
|
||||||
echo '</script>'.$nl;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -495,17 +495,23 @@ class e_db_mysql
|
|||||||
$db_time += $mytime;
|
$db_time += $mytime;
|
||||||
$this->mySQLresult = $sQryRes;
|
$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
|
// 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
|
// 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)
|
if($this->pdo)
|
||||||
{
|
{
|
||||||
$fr = $this->mySQLaccess->query('SELECT FOUND_ROWS()');
|
$rc = $this->mySQLaccess->query('SELECT FOUND_ROWS();')->fetch(PDO::FETCH_COLUMN);
|
||||||
$rc = $fr->fetchColumn();
|
$this->total_results = intval($rc);
|
||||||
$this->total_results = (int) $rc;
|
|
||||||
}
|
}
|
||||||
else /* @XXX Subject of Removal. */
|
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
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function totalResults()
|
public function foundRows()
|
||||||
{
|
{
|
||||||
return $this->total_results;
|
return $this->total_results;
|
||||||
}
|
}
|
||||||
|
@@ -409,7 +409,7 @@ class e_parse_shortcode
|
|||||||
}
|
}
|
||||||
elseif(E107_DBG_BBSC || E107_DBG_SC)
|
elseif(E107_DBG_BBSC || E107_DBG_SC)
|
||||||
{
|
{
|
||||||
echo "<h3>Couldn't Load: <b>".$path." with class-name: {$className} and pluginName {$pluginName}</b></h3>";
|
echo "<div class='alert alert-danger'>Couldn't Load: <b>".$path."</b> with class-name:<b> {$className}</b> and pluginName <b>{$pluginName}</b></div>";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -239,7 +239,7 @@ elseif ($action == 'forums')
|
|||||||
|
|
||||||
$vars->emptyVars();
|
$vars->emptyVars();
|
||||||
|
|
||||||
$ftotal = $sqlp->totalResults();
|
$ftotal = $sqlp->foundRows();
|
||||||
|
|
||||||
$parms = $ftotal.",10,".$from.",".e_REQUEST_SELF."?[FROM].forums.".$id;
|
$parms = $ftotal.",10,".$from.",".e_REQUEST_SELF."?[FROM].forums.".$id;
|
||||||
$vars->NEXTPREV = $ftotal ? $tp->parseTemplate("{NEXTPREV={$parms}}") : '';
|
$vars->NEXTPREV = $ftotal ? $tp->parseTemplate("{NEXTPREV={$parms}}") : '';
|
||||||
|
Reference in New Issue
Block a user