我想做这样的事情:
$select = $myTbl->select()
->from('download_log')
->joinLeft(...... etc........
->joinLeft(...... etc........
->joinLeft(...... etc........);
//Filter all configured bots (Google, Yahoo, etc.)
if(isset($this->_config->statistics->bots)){
$bots = explode(',',$this->_config->statistics->bots);
foreach ($bots as $bot){
$select = $select->where("user_agent NOT LIKE '%$bot%'");
}
}
$select = $select->where("download_log.download_log_ts BETWEEN '".$start_date." 00:00:00' AND '".$end_date." 23:59:59'");
但是输出的查询不正确,因为 orWhere 子句没有在唯一的 AND 子句中组合在一起。我想知道是否可以在一对括号中重新组合那些 NOT LIKE 子句。
我目前的替代方案如下:
//Filter all configured bots (Google, Yahoo, etc.)
if(isset($this->_config->statistics->bots)){
$bots = explode(',',$this->_config->statistics->bots);
foreach ($bots as $bot){
$stmt .= "user_agent NOT LIKE '%$bot%' AND ";
}
$stmt = substr($stmt,0,strlen($stmt)-4); //remove the last OR
$select = $select->where("($stmt)");
}
谢谢!