Ejemplo n.º 1
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (!$state->isUnique()) {
         if ($state->search) {
             $query->where('tbl.title LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
         }
         if ($state->table) {
             $query->where('tbl.table = :table')->bind(array('table' => $state->table));
         }
         if ($state->row) {
             $query->where('tbl.row = :row')->bind(array('row' => $state->row));
         }
         if ($state->slug) {
             $query->where('tbl.slug = :slug')->bind(array('slug' => $state->slug));
         }
         if ($state->iso_code) {
             $query->where('tbl.iso_code = :iso_code')->bind(array('iso_code' => $state->iso_code));
         }
         if (!is_null($state->status)) {
             $query->where('tbl.status = :status')->bind(array('status' => $state->status));
         }
         if (!is_null($state->deleted)) {
             $query->where('tbl.deleted = :deleted')->bind(array('deleted' => (int) $state->deleted));
         }
     }
 }
Ejemplo n.º 2
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (is_numeric($state->published)) {
         $query->where('tbl.published = :published')->bind(array('published' => (int) $state->published));
     }
     if ($state->search) {
         $query->where('(tbl.title LIKE :search)')->bind(array('search' => '%' . $state->search . '%'));
     }
     if ($state->searchword) {
         $query->where('(tbl.title LIKE :search OR tbl.introtext LIKE :search OR tbl.fulltext LIKE :search)')->bind(array('search' => '%' . $state->searchword . '%'));
     }
     if (is_numeric($state->category) || $state->category) {
         if (is_numeric($state->category)) {
             $query->where('tbl.categories_category_id IN :categories_category_id');
             if ($state->category_recurse === true) {
                 $query->where('categories.parent_id IN :categories_category_id', 'OR');
             }
             $query->bind(array('categories_category_id' => (array) $state->category));
         } else {
             $query->where('tbl.categories_category_id IS NULL');
         }
     }
     if ($state->created_by) {
         $query->where('tbl.created_by = :created_by')->bind(array('created_by' => $state->created_by));
     }
     if ($this->getTable()->isRevisable() && $state->trashed) {
         $query->bind(array('deleted' => 1));
     }
     if (is_numeric($state->access)) {
         $query->where('tbl.access <= :access')->bind(array('access' => $state->access));
     }
 }
Ejemplo n.º 3
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->search) {
         $query->where('tbl.title LIKE %:search%')->bind(array('search' => $state->search));
     }
     if ($state->table) {
         $query->where('tbl.table ' . (is_array($state->table) ? 'IN' : '=') . ' :table')->bind(array('table' => $state->table));
     }
     if (is_numeric($state->parent)) {
         $query->where('tbl.parent_id ' . (is_array($state->parent) ? 'IN' : '=') . ' :parent')->bind(array('parent' => $state->parent));
     }
     if (is_numeric($state->category)) {
         $query->where('tbl.parent_id ' . (is_array($state->category) ? 'IN' : '=') . ' :parent')->bind(array('parent' => $state->category));
     }
     if (is_bool($state->published)) {
         $query->where('tbl.published = :published');
         if ($state->table) {
             //@TODO : com_articles doesn't have a published column need to fix this
             //$query->where('content.published = :published');
         }
         $query->bind(array('published' => (int) $state->published));
     }
     if (is_bool($state->access)) {
         $query->where('tbl.access <= :access')->bind(array('access' => (int) $state->access));
     }
 }
Ejemplo n.º 4
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->application) {
         $query->where('tbl.application = :application')->bind(array('application' => $state->application));
     }
     if ($state->package && !($state->distinct && !empty($state->column))) {
         $query->where('tbl.package = :package')->bind(array('package' => $state->package));
     }
     if ($state->name) {
         $query->where('tbl.name = :name')->bind(array('name' => $state->name));
     }
     if ($state->action) {
         $query->where('tbl.action ' . (is_array($state->action) ? 'IN' : '=') . ' :action')->bind(array('action' => $state->action));
     }
     if ($state->start_date && $state->start_date != '0000-00-00') {
         // TODO: Sync this code with Date and DatabaseQuery changes.
         $start_date = $this->getObject('lib:date', array('date' => $this->getState()->start_date));
         $days_back = clone $start_date;
         $start = $start_date->addDays(1)->addSeconds(-1)->getDate();
         $query->where('tbl.created_on', '<', $start);
         $query->where('tbl.created_on', '>', $days_back->addDays(-(int) $this->getState()->days_back)->getDate());
     }
     if ($state->user) {
         $query->where('tbl.created_by = :created_by')->bind(array('created_by' => $state->user));
     }
     if ($state->ip) {
         $query->where('tbl.ip ' . (in_array($state->ip) ? 'IN' : '=') . ' :ip')->bind(array('ip' => $state->ip));
     }
     // TODO: Implement a better way to exclude information based on package/name
     $query->where('tbl.name != :name')->bind(array('name' => 'session'));
 }
Ejemplo n.º 5
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->home) {
         $query->where('tbl.home = :home')->bind(array('home' => (int) $state->home));
     }
     if ($state->menu) {
         $query->where('tbl.pages_menu_id = :menu_id')->bind(array('menu_id' => $state->menu));
     }
     if (is_bool($state->published)) {
         $query->where('tbl.published = :published')->bind(array('published' => (int) $state->published));
     }
     if (is_numeric($state->access)) {
         $query->where('tbl.access <= :access')->bind(array('access' => $state->access));
     }
     if (is_bool($state->hidden)) {
         $query->where('tbl.hidden = :hidden')->bind(array('hidden' => (int) $state->hidden));
     }
     //if(is_numeric($state->trashed)) {
     //  $query->where('tbl.trashed','=', $state->trashed);
     //}
     if (is_numeric($state->group_id)) {
         $query->where('tbl.group_id', '=', $state->group_id);
     }
     if ($state->search) {
         $query->where('tbl.title LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
     }
     if ($state->application) {
         $query->where('menus.application = :application')->bind(array('application' => $state->application));
     }
 }
Ejemplo n.º 6
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (!$state->isUnique()) {
         if ($state->search) {
             $query->where('tbl.title LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
         }
         if ($state->position) {
             $query->where('tbl.position = :position')->bind(array('position' => $state->position));
         }
         if (is_bool($state->published)) {
             $query->where('tbl.published = :published')->bind(array('published' => (int) $state->published));
         }
         if ($state->application) {
             $query->where('tbl.application = :application')->bind(array('application' => $state->application));
         }
         if ($state->extension) {
             $query->where('tbl.extensions_extension_id = :extension')->bind(array('extension' => $state->extension));
         }
         if (is_numeric($state->access)) {
             $query->where('tbl.access <= :access')->bind(array('access' => $state->access));
         }
         if (is_numeric($state->page)) {
             $query->where('module_menu.pages_page_id IN :page')->bind(array('page' => array($state->page, 0)));
         }
     }
 }
Ejemplo n.º 7
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->search) {
         $query->where('tbl.title LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
     }
 }
Ejemplo n.º 8
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->active) {
         $query->where('content.products_count > :active')->bind(array('active' => '0'));
     }
 }
Ejemplo n.º 9
0
 /**
  * Builds a WHERE clause for the query.
  *
  * @param   Library\DatabaseQuerySelect  A query object.
  * @return  void
  */
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->application) {
         $query->where('application IN :application')->bind(array('application' => (array) $state->application));
     }
     if ($state->email) {
         $query->where('tbl.email IN :email')->bind(array('email' => (array) $state->email));
     }
 }
Ejemplo n.º 10
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($user_id = $state->user_id) {
         $query->where('tbl.users_user_id = :user_id')->bind(array('user_id' => $user_id));
     }
     if ($group_id = $state->group_id) {
         $query->where('tbl.users_group_id = :group_id')->bind(array('group_id' => $group_id));
     }
 }
Ejemplo n.º 11
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     if (!$this->getState()->isUnique()) {
         if ($this->getState()->table) {
             $query->where('tbl.table = :table')->bind(array('table' => $this->getState()->table));
         }
         if ($this->getState()->row) {
             $query->where('tbl.row = :row')->bind(array('row' => $this->getState()->row));
         }
     }
 }
Ejemplo n.º 12
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (!$state->isUnique()) {
         if ($state->search) {
             $query->where('tbl.title LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
         }
         if ($state->application) {
             $query->where('tbl.application = :application')->bind(array('application' => $state->application));
         }
     }
 }
Ejemplo n.º 13
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (!$state->isUnique()) {
         if (!is_null($state->enabled)) {
             $query->where('tbl.enabled = :enabled')->bind(array('enabled' => (int) $state->enabled));
         }
         if ($state->extension) {
             $query->where('tbl.extensions_extension_id IN :extension')->bind(array('extension' => (array) $state->extension));
         }
     }
 }
Ejemplo n.º 14
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->search) {
         $query->where('tbl.name LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
     }
     if ($state->name) {
         $query->where('tbl.name = :name')->bind(array('name' => $state->name));
     }
     if (is_bool($state->enabled)) {
         $query->where('tbl.enabled = :enabled')->bind(array('enabled' => (int) $state->enabled));
     }
 }
Ejemplo n.º 15
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (!$state->isUnique()) {
         if (!is_null($state->primary)) {
             $query->where('tbl.primary = :primary')->bind(array('primary' => (int) $state->primary));
         }
         if (!is_null($state->enabled)) {
             $query->where('tbl.enabled = :enabled')->bind(array('enabled' => (int) $state->enabled));
         }
         if ($state->application) {
             $query->where('tbl.application = :application')->bind(array('application' => $state->application));
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * Build where part of query
  *
  * When getting a revision X > 1, we need to get all revisions from 1 to X, and combine the data from these into
  * one row.
  *
  * @param Library\DatabaseQuerySelect $query
  */
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->revision > 1) {
         $state->revision = range(1, $state->revision);
     }
     if ($state->status) {
         $query->where('tbl.status', '=', $state->status);
     }
     if ($state->row) {
         $query->where('tbl.row', 'IN', array($state->row));
     }
     if ($state->table && !$state->isUnique()) {
         $query->where('tbl.table', '=', $state->table);
     }
 }
Ejemplo n.º 17
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if (is_bool($state->published)) {
         $query->where('tbl.published = :published')->bind(array('published' => (int) $state->published));
     }
     if ($state->category) {
         $query->where('tbl.categories_category_id = :category')->bind(array('category' => (int) $state->category));
     }
     if ($state->search) {
         $query->where('tbl.name LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
     }
     if (is_numeric($state->access)) {
         $query->where('tbl.access <= :access')->bind(array('access' => $state->access));
     }
 }
Ejemplo n.º 18
0
 /**
  * Builds a WHERE clause for the query.
  *
  * @param   Library\DatabaseQuerySelect  A query object.
  * @return  void
  */
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->group) {
         $query->where('group.users_group_id = :group_id')->bind(array('group_id' => $state->group));
     }
     if ($state->role) {
         $query->where('tbl.users_role_id ' . ($state->group_tree ? '>=' : '=') . ' :role_id')->bind(array('role_id' => $state->role));
     }
     if (is_bool($state->enabled)) {
         $query->where('tbl.enabled = :enabled')->bind(array('enabled' => $state->enabled));
     }
     if ($state->loggedin === false) {
         $query->where('loggedin IS NULL');
     }
     if (is_bool($state->visited)) {
         $query->where('last_visited_on ' . ($state->visited ? '!=' : '=') . ' :last_visited_on')->bind(array('last_visited_on', '0000-00-00 00:00:00'));
     }
     if ($state->search) {
         $query->where('tbl.name LIKE :search')->bind(array('search' => '%' . $state->search . '%'));
     }
 }
Ejemplo n.º 19
0
 protected function _buildQueryWhere(Library\DatabaseQuerySelect $query)
 {
     parent::_buildQueryWhere($query);
     $state = $this->getState();
     if ($state->products_brand_id) {
         $query->where('tbl.products_brand_id = :products_brand_id')->bind(array('products_brand_id' => $state->products_brand_id));
     }
     if ($state->products_condition_id) {
         $query->where('tbl.products_condition_id = :products_condition_id')->bind(array('products_condition_id' => $state->products_condition_id));
     }
     if ($state->products_category_id) {
         $query->where('category.products_category_id = :products_category_id')->bind(array('products_category_id' => $state->products_category_id));
     }
     if ($state->products_group_id) {
         $query->where('tbl.products_group_id = :products_group_id')->bind(array('products_group_id' => $state->products_group_id));
     }
     if ($state->published) {
         $query->where('tbl.published = :published')->bind(array('published' => $state->published));
     }
     if ($state->featured) {
         $query->where('tbl.featured = :featured')->bind(array('featured' => $state->featured));
     }
 }