//构建where 数组
function whereBase($field_array){
$where = array();
foreach ($field_array as $temp){
$express = null;
if(is_array($temp)){
if(count($temp)>0){
$field = $temp[0];
}
if(count($temp)>1){
$express = $temp[1];
}
}else{
$field = $temp;
}
if($index = strpos($field,".") !== false){
$field = substr($field,$index+1);
}
//日期
if($express =="date"){
$begin = I($field."_begin");
$end = I($field."_end");
if(!empty($begin)){
$begin = $begin." 00:00:00";
$where[$field][] = array("gt",$begin);
}
if(!empty($end)){
$end = $end." 23:59:59";
$where[$field][] = array("lt",$end);
}
continue;
}
$value = I($field);
if(!empty($value)){
if(empty($express)){
$where[$field] = $value;
}else if ($express == "gt"){
$where[$field][] = array("gt",$value);
}else if ($express == "lt"){
$where[$field][] = array("lt",$value);
}else if ($express == "like"){
$where[$field] = array("like","%{$value}%");
}
}
}
return $where;
}
Post Views: 491