[eluser]ninjayan[/eluser]
I'm also having a problem using multiple where / or_where.
Here's the scenario:
I am checking on the database if there's a record with a 'name' or 'code' which the 'id' is not equal to the given.
Before I do the checking, I fetch a row id,name,code for example (1,office of the city mayor, ocm) then I can update either the name or code and the checking enters. If the name or code exist where id is not equal to the fetched id, then it should return false
code
Code:
$where = array(
'department_id !=' => $this->input->post('id'),
'name' => $this->input->post('department')
);
$check = $this
->db
->where($where)
->or_where('dep_code', $this->input->post('code'))
->get('departments');
if ($check->num_rows() > 0)
{
return false;
}
else
{
return true;
}
If I put a code which does not exist it works fine, but if I change/put a name that does not exist and not changing the code. it returns false.