Skip to content

Commit

Permalink
Adding sqlcalcfoundrows to Select
Browse files Browse the repository at this point in the history
  • Loading branch information
kazsaj committed Jan 18, 2022
1 parent 100ac4e commit 3ca192e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion library/Zend/Db/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
/**
* Class for SQL SELECT generation and results.
*
* Added by Docnet
* @method Zend_Db_Select joinUsing($name, $cond, $cols = '*', $schema = null)
* @method Zend_Db_Select joinInnerUsing($name, $cond, $cols = '*', $schema = null)
* @method Zend_Db_Select joinFullUsing($name, $cond, $cols = '*', $schema = null)
* @method Zend_Db_Select joinRightUsing($name, $cond, $cols = '*', $schema = null)
* @method Zend_Db_Select joinLeftUsing($name, $cond, $cols = '*', $schema = null)
*
* @category Zend
* @package Zend_Db
* @subpackage Select
Expand All @@ -44,6 +51,7 @@
class Zend_Db_Select
{

const SQL_CALC_FOUND_ROWS = 'sqlcalcfoundrows'; // Added by Docnet
const DISTINCT = 'distinct';
const COLUMNS = 'columns';
const FROM = 'from';
Expand Down Expand Up @@ -124,6 +132,7 @@ class Zend_Db_Select
* @var array
*/
protected static $_partsInit = [
self::SQL_CALC_FOUND_ROWS => false, // Added by Docnet
self::DISTINCT => false,
self::COLUMNS => [],
self::UNION => [],
Expand Down Expand Up @@ -222,6 +231,20 @@ public function distinct($flag = true)
return $this;
}

/**
* Makes the query SELECT SQL_CALC_FOUND_ROWS.
*
* Added by DN 2009-03-26
*
* @param bool $flag Whether or not to calculate the max found rows
* @return Zend_Db_Select This Zend_Db_Select object.
*/
public function sqlCalcFoundRows($flag = true)
{
$this->_parts[self::SQL_CALC_FOUND_ROWS] = (bool) $flag;
return $this;
}

/**
* Adds a FROM table and optional columns to the query.
*
Expand Down Expand Up @@ -700,7 +723,7 @@ public function getPart($part)
*
* @param integer $fetchMode OPTIONAL
* @param mixed $bind An array of data to bind to the placeholders.
* @return Zend_Db_Statement
* @return PDO_Statement|Zend_Db_Statement
*/
public function query($fetchMode = null, $bind = [])
{
Expand Down Expand Up @@ -1092,6 +1115,23 @@ protected function _renderDistinct($sql)
return $sql;
}

/**
* Render SQL_CALC_FOUND_ROWS clause
*
* Added by DN 2009-03-26
*
* @param string $sql SQL query
* @return string
*/
protected function _renderSqlcalcfoundrows($sql)
{
if ($this->_parts[self::SQL_CALC_FOUND_ROWS]) {
$sql .= ' SQL_CALC_FOUND_ROWS' ;
}

return $sql;
}

/**
* Render DISTINCT clause
*
Expand Down

0 comments on commit 3ca192e

Please sign in to comment.