你怎么能在drupal中做这样的情况?
WHERE (date = xxx and time = xxx) OR (date = xxx and time = xxx)
我想用db_select做这个条件。
感谢。
答案 0 :(得分:8)
这是我的解决方案:
$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));
答案 1 :(得分:1)
像这样:
$query = db_select('yourtable', 't');
$query->condition(db_or()->condition(db_and()->condition('t.date', xxx, '=')->condition('t.time', xxx, '='))
->condition(db_and()->condition('t.date', xxx, '=')->condition('t.time', xxx, '=')));