CodeIgniter: How to use WHERE clause and OR clause

tarnfeld picture tarnfeld · Jun 4, 2010 · Viewed 133.6k times · Source

I am using the following code to select from a MySQL database with a Code Igniter webapp:

$query = $this->db->get_where('mytable',array('id'=>10));

This works great! But I want to write the following MySQL statement using the CI library?

SELECT * FROM `mytable` WHERE `id`='10' OR `field`='value'

Any ideas? Thanks!

Answer

Dylan picture Dylan · Jun 4, 2010
$where = "name='Joe' AND status='boss' OR status='active'";

$this->db->where($where);