Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Condition AND OR with Drupal db_select

Hi how can i do a condition like that in drupal ?

WHERE (date = xxx and time = xxx) OR (date = xxx and time = xxx)

I want to do this condition with db_select.

Thanks.

like image 851
altore Avatar asked Dec 21 '25 10:12

altore


1 Answers

thx for fast answer, i just found it.

here is my solution :

$and_1 = db_and()->condition('b.date' , $date, '=')->condition('b.time', $begin_time, '>');
$and_2 = db_and()->condition('b.date' , $tomorrow, '=')->condition('b.time', '00:00', '>=')

$query->condition(db_or()->condition($and_1)->condition($and_2));
like image 189
altore Avatar answered Dec 23 '25 23:12

altore



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!