thinkphp3.2一个复杂的查询语句
function buildWhere($where = array(), $searchFields = '')
{
if(empty($searchFields)) {
$searchFields = 'start_time|end_time';
$fs = 'start_time';
$fe = 'end_time';
} else {
list($fs, $fe)= explode('|', $searchFields);
}
$dataWhere[$searchFields] = array('between', array($startTime, $endTime));
$dateInWhere[$fs] = array('lt', $startTime);
$dateInWhere[$fe] = array('gt', $endTime);
$dataWhere['_complex'] = $dateInWhere;
$dataWhere['_logic'] = 'OR';
$where['_complex'] = $dataWhere;
}
return $where;
}