根据要搜索的接收的数据 接收到后 对要搜索的进行拼接
列如以下:
public function searchby(){
//接收到数据
$admin_name = trim(I("get.admin_name"));
$email = trim(I("get.email"));
$phone = trim(I("get.phone"));
$status = trim(I("get.status"));
//判断
if (!empty($admin_name) && isset($admin_name) && $admin_name!='0' ) {
$where = " admin_name like '%$admin_name%'";
}
//判断
if ( !empty($email) && isset($email) && $email!='0') {
if ( !empty($admin_name) && isset($admin_name) && $admin_name!='0') {
$where .= " AND email = '$email'";
}else{
$where .= " email = '$email'";
}
}
//判断
if ( !empty($phone) && isset($phone) && $phone!='0' ) {
if ( !empty($admin_name) && isset($admin_name) && $admin_name!='0') {
$where .= " AND phone = '$phone' ";
}else{
if ( !empty($email) && isset($email) && $email!='0') {
$where .= " AND phone = '$phone' ";
}else{
$where = "phone = '$phone' ";
}
}
}
//判断
if ( !empty($status) && isset($status) && $status!='0' ) {
if ( !empty($admin_name) && isset($admin_name) && $admin_name!='0') {
$where .= " AND status = '$status' ";
}else{
if ( !empty($email) && isset($email) && $email!='0') {
$where .= " AND status = '$status' ";
}else{
if ( !empty($phone) && isset($phone) && $phone!='0' ) {
$where .= " AND status = '$status' ";
}else{
$where = " status = '$status' ";
}
}
}
}
//echo $where;exit;
return $this
->table()
->join('user ON user.u_id = arrearge.u_id ')
->join('money_type ON money_type.m_t_id = arrearge.m_t_id')
->where($where)
->select();
}