3

嗨我怎么能在drupal中做这样的条件?

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

我想用 db_select 做这个条件。

谢谢。

4

2 回答 2

8

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));
于 2013-04-15T13:04:51.053 回答
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, '=')));
于 2013-04-15T12:57:50.090 回答