CodeIgniter Forums
Active record help - 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: Active record help (/showthread.php?tid=40165)



Active record help - El Forum - 03-31-2011

[eluser]Unknown[/eluser]
I need to produce a where clause that looks like this:

WHERE messages.thread_id = 40 AND (messages.author = 10 or messages.recipient = 15)

I have tried where() and or_where but it produces
where messages.thread_id = 40 AND messages.author = 10 OR messages.recipient = 15

which of course does not give me the results I need.

Thanks!


Active record help - El Forum - 03-31-2011

[eluser]danmontgomery[/eluser]
Code:
$this->db->where('messages.thread_id', 40);
$this->db->where('(`messages`.`author` = 10 OR `messages`.`recipient` = 15)', NULL, FALSE);



Active record help - El Forum - 03-31-2011

[eluser]Unknown[/eluser]
Perfect, thanks.

Just before your reply I created a string and pasted that into the where(); Some results, but you solution is just 1 line so I will go with that!

Thanks Again!