-
-
Save mpmont/1774109 to your computer and use it in GitHub Desktop.
novo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetArticles($options = array()) { | |
// QUALIFICATION | |
if (isset($options['idarticle'])) | |
$this->db->where('idarticle', $options['idarticle']); | |
if (isset($options['idcategory'])) | |
$this->db->where('idcategory', $options['idcategory']); | |
if (isset($options['articletitle'])) | |
$this->db->where('articletitle', $options['articletitle']); | |
if (isset($options['articlestatus'])) | |
$this->db->where('articlestatus', $options['articlestatus']); | |
if (isset($options['articleimage'])) | |
$this->db->where('articleimage', $options['articleimage']); | |
if (isset($options['search-term'])){ | |
$this->db->or_like('articletitle', $options['search-term']); | |
$this->db->or_like('articleintro', $options['search-term']); | |
$this->db->or_like('articledescription', $options['search-term']); | |
} | |
//so you don't get any deleted values | |
if(!isset($options['articlestatus'])) $this->db->where('articlestatus !=', 'deleted'); | |
// LIMIT OFFSET | |
if (isset($options['limit']) && isset($options['offset'])) | |
$this->db->limit($options['limit'], $options['offset']); | |
elseif (isset($options['limit'])) | |
$this->db->limit($options['limit']); | |
// SORT | |
if (isset($options['sortBy']) && isset($options['sortDirection'])) | |
$this->db->order_by($options['sortBy'], $options['sortDirection']); | |
$query = $this->db->get('articles'); | |
if(isset($options['count'])) return $query->num_rows(); | |
if (isset($options['idarticle'])) | |
return $query->row(0); | |
return $query->result(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$data['articles'] = $this->article->limit($page['per_page'], $offset)->order_by('id', 'DESC')->get_many_by('articlestatus !=', 'deleted'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment