protected function _getcount_common($data = array(), $_caller = NULL) { if (empty($data['sort'])) { $data['sort'] = 'label'; } else { $data = array('sort' => 'label'); } // -------------------------------------------------------------------------- if (!empty($data['include_count'])) { if (empty($this->db->ar_select)) { // No selects have been called, call this so that we don't *just* get the product count $_prefix = $this->_table_prefix ? $this->_table_prefix . '.' : ''; $this->db->select($_prefix . '*'); } $this->db->select('(SELECT COUNT(*) FROM ' . NAILS_DB_PREFIX . 'shop_product_range WHERE range_id = ' . $this->_table_prefix . '.id) product_count'); } // -------------------------------------------------------------------------- return parent::_getcount_common($data, $_caller); }
protected function _getcount_common($data = NULL, $_caller = NULL) { parent::_getcount_common($data); // -------------------------------------------------------------------------- // Set the select if ($_caller !== 'COUNT_ALL') { $this->db->select($this->_table_prefix . '.*, u.first_name, u.last_name, u.gender, u.profile_img, ue.email'); } // Join user tables $this->db->join(NAILS_DB_PREFIX . 'user u', 'u.id = ' . $this->_table_prefix . '.user_id', 'LEFT'); $this->db->join(NAILS_DB_PREFIX . 'user_email ue', 'ue.user_id = ' . $this->_table_prefix . '.user_id AND ue.is_primary = 1', 'LEFT'); // Set the order $this->db->order_by($this->_table_prefix . '.created', 'DESC'); $this->db->order_by($this->_table_prefix . '.id', 'DESC'); }
/** * Applies common conditionals * * This method applies the conditionals which are common across the get_*() * methods and the count() method. * * @access public * @param string $data Data passed from the calling method * @param string $_caller The name of the calling method * @return void **/ protected function _getcount_common($data = NULL, $_caller = NULL) { parent::_getcount_common($data, $_caller); // -------------------------------------------------------------------------- $this->db->select('bp.id, bp.slug, bp.title, bp.image_id, bp.excerpt, bp.seo_title'); $this->db->select('bp.seo_description, bp.seo_keywords, bp.is_published, bp.is_deleted, bp.created, bp.created_by, bp.modified, bp.modified_by, bp.published'); $this->db->select('u.first_name, u.last_name, ue.email, u.profile_img, u.gender'); $this->db->join(NAILS_DB_PREFIX . 'user u', 'bp.modified_by = u.id', 'LEFT'); $this->db->join(NAILS_DB_PREFIX . 'user_email ue', 'ue.user_id = u.id AND ue.is_primary = 1', 'LEFT'); // -------------------------------------------------------------------------- if (!empty($data['include_body'])) { $this->db->select('bp.body'); } // -------------------------------------------------------------------------- if (!empty($data['search'])) { $this->db->or_like($this->_table_prefix . '.title', $data['search']); $this->db->or_like($this->_table_prefix . '.excerpt', $data['search']); $this->db->or_like($this->_table_prefix . '.body', $data['search']); $this->db->or_like($this->_table_prefix . '.seo_description', $data['search']); $this->db->or_like($this->_table_prefix . '.seo_keywords', $data['search']); } }