Welcome Guest, Not a member yet? Register   Sign In
Active Records
#4

[eluser]RobertB.[/eluser]
Thank you all, this works fine. I did not know about or_where() clause.
Code:
$this->db->select('s.id, s.state, COUNT(b.is_active) AS active');
$this->db->from('states AS s');
$this->db->join('businesses AS b', 's.id = b.state_id', 'left');
$this->db->where('b.cat_id', $this->uri->segment(3));
$this->db->or_where('b.state_id', null);
$this->db->groupby('s.id');
Stef, what do you mean by "$this->uri->segment(3) is not sanitized" and how can I sanitize the code.

Thanks,
Robert


Messages In This Thread
Active Records - by El Forum - 03-04-2010, 08:13 PM
Active Records - by El Forum - 03-05-2010, 02:42 AM
Active Records - by El Forum - 03-05-2010, 02:56 AM
Active Records - by El Forum - 03-05-2010, 07:45 AM
Active Records - by El Forum - 03-05-2010, 09:07 AM
Active Records - by El Forum - 03-05-2010, 01:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB