左关联查询:
function gdsearch()
{
$con = $_POST['content'];
if (!empty($con)) {
$sql = "select waiqin.*,users.header from waiqin left join users on waiqin.uid=users.uid where waiqin.person='".$con."' or waiqin.cause='".$con."' or waiqin.time like '%$con%' ";
$res = M()->query($sql);
if ($res) {
$code = array('code' => 1, 'message' => '请求成功');
$result['list'] = $res;
echo json_encode(array_merge($code,$result));
} else {
$code = array('code' => 2, 'message' => '没有数据');
echo json_encode($code);
}
}
}
时间段查询(between):
if (!empty($data['uid']) && !empty($time1) && !empty($time2)){
$sql = "select * from waiqin where time between ('".$time1."') and ('".$time2."') and uid in (".$data['uid'].")";
$res = M()->query($sql);
if($res!=null && $res!=false){
$dc['content'] = $res;
$excel = M('dcexcel')->add($data);
if($excel){
$code = array('code'=>1,'message'=>'添加导出记录成功');
echo json_encode($code,$dc);
}else{
$code = array('code'=>2,'message'=>'添加记录失败');
echo json_encode($code);
}
}else{
$code = array('code'=>2,'message'=>'导出记录失败');
echo json_encode($code);
}
}