CodeIgniter Forums
get_where question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: get_where question (/showthread.php?tid=12805)



get_where question - El Forum - 10-31-2008

[eluser]Fenix[/eluser]
I am trying to write a query with CI where I want to select all posts in a database that have the status (an enum data type) of anything but "deleted". How would I write this code?

Code:
$this->db->select('post_id,title,name,type,status,description');
return $this->db->get_where('posts', array('post_status' != 'deleted'))->result();

I assume what I have (!=) is wrong. What is the correct way to do this?
Other statuses are "published" or "private".

Thanks!


get_where question - El Forum - 10-31-2008

[eluser]Colin Williams[/eluser]
Include the != in the array key:

Code:
$this->db->get_where('posts', array('post_status !=' => 'deleted'))->result();

Double-check the docs if you are unsure.


get_where question - El Forum - 01-13-2009

[eluser]onsetrese[/eluser]
tnx a lot, that answers our question of how to have a negation in get_where function