File indexing completed on 2024-12-22 05:36:23

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  *
0022  * Created: 27.09.2017
0023  */
0024 
0025 class Local_Db_Select_Mysql extends Zend_Db_Select
0026 {
0027     const SQL_CALC_FOUND_ROWS = 'sqlCalcFoundRows';
0028 
0029     // add other options as needed
0030 
0031     public function __construct(Zend_Db_Adapter_Abstract $adapter)
0032     {
0033         /**
0034          * Use array_merge() instead of simply setting a key
0035          * because the order of keys is significant to the
0036          * rendering of the query.
0037          */
0038         self::$_partsInit = array_merge(array(
0039             self::SQL_CALC_FOUND_ROWS => false
0040             // add other options as needed
0041         ), self::$_partsInit);
0042         parent::__construct($adapter);
0043     }
0044 
0045     public function sqlCalcFoundRows($flag = true)
0046     {
0047         $this->_parts[self::SQL_CALC_FOUND_ROWS] = (bool)$flag;
0048 
0049         return $this;
0050     }
0051 
0052     protected function _renderSqlCalcFoundRows($sql)
0053     {
0054         if ($this->_parts[self::SQL_CALC_FOUND_ROWS]) {
0055             $sql .= ' SQL_CALC_FOUND_ROWS';
0056         }
0057 
0058         return $sql;
0059     }
0060 
0061 }