×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: bejoy balan
Added: Sep 8, 2014 10:46 AM
Views: 14
Override Vaire/data/collection.db.php getSelectountSQL;
  1.  public function getSelectCountSql()
  2.     {
  3.         $this->_renderFilters();
  4.  
  5.         $countSelect = clone $this->getSelect();
  6.         $countSelect->reset(Zend_Db_Select::ORDER);
  7.         $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);
  8.         $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
  9.         $countSelect->reset(Zend_Db_Select::COLUMNS);
  10.  
  11.         if(count($this->getSelect()->getPart(Zend_Db_Select::GROUP)) > 0) {
  12.             $countSelect->reset(Zend_Db_Select::GROUP);
  13.             $countSelect->distinct(true);
  14.             $group = $this->getSelect()->getPart(Zend_Db_Select::GROUP);
  15.             $countSelect->columns("COUNT(DISTINCT ".implode(", ", $group).")");
  16.         } else {
  17.             $countSelect->columns('COUNT(*)');
  18.         }
  19.         return $countSelect;
  20.     }