Welcome Guest, Not a member yet? Register   Sign In
get_where question

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?

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".


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

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

Double-check the docs if you are unsure.

tnx a lot, that answers our question of how to have a negation in get_where function

Theme © iAndrew 2016 - Forum software by © MyBB