mirror of
https://github.com/e107inc/e107.git
synced 2025-07-29 02:40: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 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 '<script type="text/javascript">'.$nl;
|
||||
}
|
||||
$text = '';
|
||||
|
||||
switch($type) {
|
||||
case 'log':
|
||||
echo 'console.log("'.$name.'");'.$nl;
|
||||
$text .= 'console.log("'.$name.'");'.$nl;
|
||||
break;
|
||||
case 'info':
|
||||
echo 'console.info("'.$name.'");'.$nl;
|
||||
$text .= 'console.info("'.$name.'");'.$nl;
|
||||
break;
|
||||
case 'warning':
|
||||
echo 'console.warn("'.$name.'");'.$nl;
|
||||
$text .= 'console.warn("'.$name.'");'.$nl;
|
||||
break;
|
||||
case 'error':
|
||||
echo 'console.error("'.$name.'");'.$nl;
|
||||
$text .= 'console.error("'.$name.'");'.$nl;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1902,22 +1898,22 @@ class e107
|
||||
{
|
||||
$object = json_encode($var);
|
||||
|
||||
echo '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 object'.preg_replace('~[^A-Z|0-9]~i',"_",$name).' = \''.str_replace("'","\'",$object).'\';'.$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)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1926,25 +1922,23 @@ class e107
|
||||
switch($type)
|
||||
{
|
||||
case 'log':
|
||||
echo 'console.debug("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||
$text .= 'console.debug("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||
break;
|
||||
case 'info':
|
||||
echo 'console.info("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||
$text .= 'console.info("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||
break;
|
||||
case 'warning':
|
||||
echo 'console.warn("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||
$text .= 'console.warn("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||
break;
|
||||
case 'error':
|
||||
echo 'console.error("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||
$text .= 'console.error("'.str_replace('"','\\"',$var).'");'.$nl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($js != true)
|
||||
{
|
||||
echo '</script>'.$nl;
|
||||
}
|
||||
|
||||
e107::js('footer-inline', $text);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -409,7 +409,7 @@ class e_parse_shortcode
|
||||
}
|
||||
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();
|
||||
|
||||
$ftotal = $sqlp->totalResults();
|
||||
$ftotal = $sqlp->foundRows();
|
||||
|
||||
$parms = $ftotal.",10,".$from.",".e_REQUEST_SELF."?[FROM].forums.".$id;
|
||||
$vars->NEXTPREV = $ftotal ? $tp->parseTemplate("{NEXTPREV={$parms}}") : '';
|
||||
|
Reference in New Issue
Block a user