CodeIgniter ActiveRecord Query how to query mutliple AND/ORs

zamocny

New Member
I have a table layout as such:
DVfay.jpg
The code in my model is:\[code\] //$searchTerms is the companies name, or part of it. e.g: Brass function searchCompanyName($searchTerms, $strict = FALSE, $params = array() ){ if ($strict == TRUE){ $this->db->where('fieldvalue', $searchTerms); }else{ $this->db->like('fieldvalue', $searchTerms, 'after'); } $this->db->where('fieldid', '19'); if(isset($params['deals']) && $params['deals'] == true){ $this->db->where("fieldid = '33' AND fieldvalue != ''"); } $query = $this->db->select('pointid')->get('map_userfields'); if ($query->num_rows() < 1){ return false; }else{ return $query->result_array(); }}\[/code\]What i am trying to do is get a pointId for any company (fieldid 19) thats LIKE AND promotions (fieldid 33) is not empty.How can i do this effectively using CI and activeRecords.
 
Back
Top