嗨我怎么能在drupal中做这样的条件?
WHERE (date = xxx and time = xxx) OR (date = xxx and time = xxx)
我想用 db_select 做这个条件。
谢谢。
嗨我怎么能在drupal中做这样的条件?
WHERE (date = xxx and time = xxx) OR (date = xxx and time = xxx)
我想用 db_select 做这个条件。
谢谢。
thx 快速回答,我刚刚找到它。
这是我的解决方案:
$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));
像这样:
$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, '=')));