how to do this query |
[eluser]gebe[/eluser]
how to do this query with active record class? WHERE (field = 'negocio' OR field IS NULL) AND other_field = 1 Thanks
[eluser]Clooner[/eluser]
What did you try yourself? How AR works is really well documented: http://ellislab.com/codeigniter/user-gui...tml#select.
[eluser]siubie[/eluser]
hai interesting, dunno this is my bad on my code @_@ if i make this AR Code: $this->db->where('field1',$var1); result in query Code: where field1=john and name=doe and gotcha=hehe maybe this question point to how we make the query to Code: where ( field1=john or name=doe ) and gotcha=hehe
[eluser]danmontgomery[/eluser]
AR doesnt' support grouped where statements, you woulud need to do it manually. Code: $this->db->where('(`field1` = "'.$var1.'" OR `field2` IS NULL)', null, false)->where('field3', 'some value');
[eluser]gebe[/eluser]
Hi Clonner, I already read the document, but is not enought for do my query. I try with or_where, where_in, etc, etc Exactly siubie I need the query: WHERE (field=x OR field IS NULL) AND field_2 = b
[eluser]Clooner[/eluser]
[quote author="gebe" date="1276829361"]Hi Clonner, I already read the document, but is not enought for do my query. I try with or_where, where_in, etc, etc Exactly siubie I need the query: WHERE (field=x OR field IS NULL) AND field_2 = b[/quote] From the manual Code: $where = "name='Joe' AND status='boss' OR status='active'"; change it into Code: $where = "(name='Joe' OR status='active') AND status='boss' "; |
Welcome Guest, Not a member yet? Register Sign In |