示例#1
0
 /**
  * Builds LEFT JOINS clauses for the query.
  *
  * @param   Library\DatabaseQuerySelect  A query object.
  * @return  void
  */
 protected function _buildQueryJoins(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     $query->join(array('session' => 'users_sessions'), 'tbl.email = session.email', $state->loggedin ? 'RIGHT' : 'LEFT');
     $query->join(array('role' => 'users_roles'), 'role.users_role_id = tbl.users_role_id');
     $query->join(array('group' => 'users_groups_users'), 'group.users_user_id = tbl.users_user_id');
 }
示例#2
0
 protected function _buildQueryGroup(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     if ($state->distinct) {
         $query->group('tbl.email');
     }
 }
示例#3
0
 protected function _buildQueryOrder(Library\DatabaseQuerySelect $query)
 {
     if ($this->getState()->distinct && !empty($this->getState()->column)) {
         $query->order('package', 'asc');
     } else {
         parent::_buildQueryOrder($query);
     }
 }
示例#4
0
 protected function _buildQueryJoins(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     // Only include joins when we want to list the categories that are attached to a product
     if ($state->active) {
         $subquery = $this->getObject('lib:database.query.select')->columns(array('products_brand_id', 'products_count' => 'COUNT(DISTINCT products_product_id)'))->table('products_products')->where('published = :published')->bind(array('published' => '1'))->group('products_brand_id');
         $query->join(array('content' => $subquery), 'content.products_brand_id = tbl.products_brand_id');
     }
 }
示例#5
0
 protected function _buildQueryOrder(Library\DatabaseQuerySelect $query)
 {
     if ($this->sort == 'table') {
         $direction = strtoupper($this->direction);
         $query->order('tbl.table', $direction);
         $query->order('tbl.row', $direction);
         $query->order('tbl.original', 'DESC');
     }
 }
示例#6
0
 protected function _buildQueryOrder(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     $direction = strtoupper($state->direction);
     if ($state->sort == 'ordering') {
         $query->order('category_title', 'ASC')->order('ordering', $direction);
     } else {
         $query->order($state->sort, $direction)->order('category_title', 'ASC')->order('ordering', 'ASC');
     }
 }
示例#7
0
 protected function _buildQueryGroup(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     if ($state->distinct) {
         $query->distinct();
         $query->group($state->distinct);
     } else {
         $query->group('tbl.categories_category_id');
     }
 }
示例#8
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     if ($state->search) {
         $query->where('tbl.title LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
     }
     if ($this->getState()->table) {
         $query->where('tbl.table = :table')->bind(array('table' => $this->getState()->table));
     }
     parent::_buildQueryWhere($query);
 }
 protected function _buildQueryOrder(Library\DatabaseQuerySelect $query)
 {
     $sort = $this->getState()->sort;
     $direction = strtoupper($this->getState()->direction);
     if ($sort) {
         $column = $this->getTable()->mapColumns($sort);
         if (array_key_exists($column, $this->getTable()->getColumns())) {
             $query->order($column, $direction);
         }
     }
 }
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     if (!$this->getState()->isUnique()) {
         if ($this->getState()->table) {
             $query->where('relations.table = :table')->bind(array('table' => $this->getState()->table));
         }
         if ($this->getState()->row) {
             $query->where('relations.row IN :row')->bind(array('row' => (array) $this->getState()->row));
         }
     }
     parent::_buildQueryWhere($query);
 }
示例#11
0
 protected function _buildQueryJoins(Library\DatabaseQuerySelect $query)
 {
     $query->join(array('group' => 'users_groups'), 'group.users_group_id = tbl.users_group_id');
 }
示例#12
0
 protected function _buildQueryOrder(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     $direction = strtoupper($state->direction);
     $query->order('section.title', $direction)->order('tbl.title', $direction);
 }
示例#13
0
 /**
  * Builds LEFT JOINS clauses for the query.
  *
  * @param   Library\DatabaseQuerySelect  A query object.
  * @return  void
  */
 protected function _buildQueryJoins(Library\DatabaseQuerySelect $query)
 {
     $state = $this->getState();
     $query->join(array('users' => 'users'), 'tbl.email = users.email');
 }
示例#14
0
 protected function _buildQueryOrder(Library\DatabaseQuerySelect $query)
 {
     $query->order('tbl.revision', 'desc');
 }
示例#15
0
 protected function _buildQueryGroup(Library\DatabaseQuerySelect $query)
 {
     $query->group('tbl.email');
 }