Esempio n. 1
0
 /**
  * Count results
  *
  * @return int
  */
 public function count()
 {
     if ($this->_rowCount === null) {
         $this->_rowCount = $this->_query->count();
     }
     return $this->_rowCount;
 }
Esempio n. 2
0
 /**
  * Return the total of records
  *
  * @return integer
  */
 public function getTotalRecords()
 {
     if ($this->_totalRecords > 0) {
         return $this->_totalRecords;
     }
     return (int) $this->_query->count();
 }
 public function count($params = array())
 {
     $breadcrumb = $this->getBreadcrumb();
     $result = parent::count($params);
     $this->restoreBreadcrumb($breadcrumb);
     return $result;
 }
Esempio n. 4
0
 /**
  * Return the total of records
  *
  * @return integer
  */
 public function getTotalRecords()
 {
     return (int) $this->_query->count();
 }
Esempio n. 5
0
 /**
  * getRecords
  * Get records from the DB
  * @return mixed
  */
 public function getRecords(Doctrine_Query $dq, $currentPage = 1, $rowNum = 2, array $sort = array(), array $where = array())
 {
     $uri = "";
     $module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
     $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
     // Defining the url sort
     if (!empty($sort)) {
         foreach ($sort as $s) {
             $arrSort[] = "/sort/" . str_replace(" ", ",", $s);
         }
         $arrSort = array_unique($arrSort);
         $uri = implode("", $arrSort);
     }
     $pagerLayout = new Doctrine_Pager_Layout(new Doctrine_Pager($dq, $currentPage, $rowNum), new Doctrine_Pager_Range_Sliding(array('chunk' => 10)), "/{$module}/{$controller}/list/page/{%page_number}" . $uri);
     // Get the pager object
     $pager = $pagerLayout->getPager();
     // Set the Order criteria
     if (!empty($sort)) {
         $pager->getQuery()->orderBy(implode(", ", $sort));
     }
     if (isset($where) && is_array($where)) {
         foreach ($where as $filters) {
             if (isset($filters[0]) && is_array($filters[0])) {
                 foreach ($filters as $filter) {
                     $method = $filter['method'];
                     $value = $filter['value'];
                     $criteria = $filter['criteria'];
                     $pager->getQuery()->{$method}($criteria, $value);
                 }
             } else {
                 $method = $filters['method'];
                 $value = $filters['value'];
                 $criteria = $filters['criteria'];
                 $pager->getQuery()->{$method}($criteria, $value);
             }
         }
     }
     $pagerLayout->setTemplate('<a href="{%url}">{%page}</a> ');
     $pagerLayout->setSelectedTemplate('<a class="active" href="{%url}">{%page}</a> ');
     $this->data = $pagerLayout->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     $this->paging = $pagerLayout->display(null, true);
     $this->recordcount = $dq->count();
     #print_r ( $this->data );
     return $this;
 }
 public function testAggregateFunctionsInOrderByAndHavingWithCount()
 {
     $q = new Doctrine_Query();
     
     $q->select('u.*, COUNT(a.id) num_albums')
       ->from('User u')
       ->leftJoin('u.Album a')
       ->orderby('num_albums desc')
       ->groupby('u.id')
       ->having('num_albums > 0')
       ->limit(5);
     
     try {
         $q->count();
         $this->pass();
     } catch (Doctrine_Exception $e) {
         $this->fail();
     }
 }
 public function testCountWithGroupBy()
 {
     $q = new Doctrine_Query();
     $q->from('User u');
     $q->leftJoin('u.Phonenumber p');
     $q->groupBy('p.entity_id');
     $this->assertEqual($q->count(), $q->execute()->count());
 }
 public function testAggregateFunctionsInOrderByAndHavingWithCount()
 {
     $q = new Doctrine_Query();
     $q->select('u.*, COUNT(a.id) num_albums')->from('User u')->leftJoin('u.Album a')->orderby('num_albums desc')->groupby('u.id')->having('num_albums > 0')->limit(5);
     try {
         $this->assertEqual($q->getCountQuery(), 'SELECT COUNT(*) AS num_results FROM (SELECT e.id, COUNT(a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.type = 0 GROUP BY e.id HAVING a__0 > 0) dctrn_count_query');
         $q->count();
         $this->pass();
     } catch (Doctrine_Exception $e) {
         $this->fail($e->getMessage());
     }
 }
 /**
  * Get total from a Doctrine_Query object.
  *
  * @param Doctrine_Query $q
  * @return int  $total
  */
 protected function rec_query_total(Doctrine_Query $q)
 {
     return $q->count();
 }
Esempio n. 10
0
 /**
  * Get the item count
  * 
  * @return integer
  */
 public function count()
 {
     return $this->_query->count();
 }