Exemplo n.º 1
0
 protected function _buildQueryColumns(Library\DatabaseQuerySelect $query)
 {
     if (!$this->getState()->isUnique()) {
         $query->columns(array('count' => 'COUNT(relations.attachments_attachment_id)'))->columns('table')->columns('row');
     }
     return parent::_buildQueryColumns($query);
 }
Exemplo n.º 2
0
 protected function _buildQueryJoins(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     //Exclude joins if counting records
     if (!$query->isCountQuery()) {
         if ($state->table) {
             $query->columns(array('count'));
             $subquery = $this->getObject('lib:database.query.select')->columns(array('categories_category_id', 'count' => 'COUNT(categories_category_id)'))->table($state->table)->group('categories_category_id');
             $query->join(array('content' => $subquery), 'content.categories_category_id = tbl.categories_category_id')->join(array('attachments' => 'attachments'), 'attachments.attachments_attachment_id = tbl.attachments_attachment_id')->join(array('thumbnails' => 'files_thumbnails'), 'thumbnails.filename = attachments.path');
         }
     }
     parent::_buildQueryJoins($query);
 }