Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter mysql where not equal to query

Mysql codeigniter query is not working properly. Suppose if mysql table looks like this:

 user_id|user_name
       1|john
       2|alex
       3|sam

Here user_name is unique

The following query should return false if user_name=john and user_id=1 and true if say user_name=john and user_id=2.

$this->db->get_where('user', array('user_name' => $name,'user_id !=' => $userid));

But it returns true in the case user_name=john and user_id=1.

Can anyone suggest me an alternative way of querying not equal to.

print($this->db->last_query()) gives:

SELECT * FROM (user) WHERE user_name = 'john' AND user_id != '1'

like image 499
Avinash Avatar asked Feb 01 '13 04:02

Avinash


1 Answers

Why dont you use simple $this->db->query('your query');

like image 131
rohitarora Avatar answered Sep 20 '22 04:09

rohitarora