我想用 cakephp 进行这样的查询:
WHERE text LIKE '%keyword%'
AND
(
(text LIKE '%something%')
OR (text LIKE '%something%')
OR (...)
)
AND
(
(text LIKE '%other%')
OR (text LIKE '%other%')
OR (...)
)
NOT
(
(text LIKE '%dont include%')
OR (text LIKE '%dont include%')
OR (...)
)
这是我的 $conditions 代码:
$conditions = array
(
'Tweet.text LIKE' => '%keyword%',
'AND' => array(
array(
'OR' => array(
// topic
array('Tweet.text LIKE' => '%something%'),
array('Tweet.text LIKE' => '%something%')
)
),
array(
'OR' => array(
// sentiment
array('Tweet.text LIKE' => '%other%'),
array('Tweet.text LIKE' => '%other%')
)
)
),
'NOT' => array(
array('Tweet.text LIKE' => '%dont include%'),
array('Tweet.text LIKE' => '%dont include%')
)
);
我正在使用 Debugger::dump() 方法显示结果,结果只是使用最后一个“或”条件,而不是两个“或”条件:
array(
'Tweet.text LIKE' => '%keyword%',
'OR' => array(
(int) 0 => array(
'Tweet.text LIKE' => '%other%'
),
(int) 1 => array(
'Tweet.text LIKE' => '%other%'
)
),
'NOT' => array(
(int) 0 => array(
'Tweet.text LIKE' => '%dont include%'
),
(int) 1 => array(
'Tweet.text LIKE' => '%dont include%'
)
)
)
我的问题是,如何进行同时使用“或”条件的查询?
请尽快回复..提前谢谢:)