To cut a long story short: Is it possible and if it is - how can I build a query that looks somewhat like this one
SELECT * FROM a
WHERE row = 1 AND
$this->db->where('salary_range_min >= ',$salarymin)
$this->db->where('salary_range_max <= ',$salarymax)
$this->db->where('job_title like '.$title.'% or skill like %'.$title.'%');
// OR */
$this->db->where('job_title like '.$title.'% or skill like %'.$title.'%',FALSE);
// OR */
$this->db->where('job_title like '.$title.'% or skill like %'.$title.'%',NULL);
Try this out
You can use the following:
$this->db->like('title', 'match', 'before');
It will produce:
WHERE `title` LIKE '%match' ESCAPE '!'
Why dont you try this:
$this->db->where("row = 1 AND
(other_row LIKE '%..%' OR another_row LIKE '%..%')");
$this->db->get('a');
It's how you can write custom WHERE in CI. If it is not what u r looking for, feel free to explain
You can try this.
$query = $this->db->select('*')
->from('a')
->where('row',1)
->where("(other_row LIKE '%%' OR another_row LIKE '%%' )")
->get();
foreach ($query->result() as $row) {
//do sth.
}
You can write custom query string (from active record class)
Custom string:
You can write your own clauses manually:
$where = "name='Joe' AND status='boss' OR status='active'";
$this->db->where($where);
I also having problem with or_where
so i simply make my custom query like
$this->db->query("SELECT * FROM `a` WHERE `row`=1 AND (CONDITION1 OR CONDITION2)")
$sql= "SELECT * FROM `a`
WHERE row = '1' AND
(other_row LIKE '%" . $value . "%' OR another_row LIKE '%" . $value . "%')";
$this->db->query($sql);