From 3ca192e4e53340a8ca017c364a57d9eee85937e7 Mon Sep 17 00:00:00 2001 From: kazsaj Date: Tue, 18 Jan 2022 13:52:29 +0000 Subject: [PATCH] Adding sqlcalcfoundrows to Select --- library/Zend/Db/Select.php | 42 +++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/library/Zend/Db/Select.php b/library/Zend/Db/Select.php index f411bb6d7e..4f3206ccf6 100644 --- a/library/Zend/Db/Select.php +++ b/library/Zend/Db/Select.php @@ -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 @@ -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'; @@ -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 => [], @@ -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. * @@ -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 = []) { @@ -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 *