Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter AND OR AND [duplicate]

It is posible to do: (condition 1 AND condition2) OR (condition3 AND condition4) in codigniter?

I try:

$this->db->where(condition1 - condition2);
$this->db->or_where(condition3 - condition4);

But this is: (condition1 AND condition2) OR (condition3 OR condition4)

like image 497
Tony Avatar asked Aug 24 '26 08:08

Tony


2 Answers

Just write it out in your where

$this->db->where("(condition1 AND condition2) OR (condition3 AND condition4)");

this will still escape data and you don't have to fool with the or_where method.

like image 68
Cody Covey Avatar answered Aug 26 '26 04:08

Cody Covey


yes it is possible,for convenience take whatever conditions you want to used into one variable

$where ="(condition 1 AND condition2) OR (condition3 AND condition4)";
$this->db->where($where);
like image 22
Needhi Agrawal Avatar answered Aug 26 '26 03:08

Needhi Agrawal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!