Welcome Guest, Not a member yet? Register   Sign In
sql return all rows
#1

Dear all,

I have below SQL but does not know where is the problem???
//--------------Return all rows, cannot filter by userID-------------------------//
$arr=array("status"=>"Op", "userID"=>$userId);
$farr=array("status"=>"R", "fUserID"=>$userId);
$Inarr=array("status"=>"OC", "userID"=>$userId);
$Outarr=array("status"=>"C", "fUserID"=>$userId);
$this->db->where($arr);
$this->db->or_where($farr);
$this->db->or_where($Inarr);
$this->db->or_where($Outarr);
$query = $this->db->from('message')->where($arr)->or_where($farr)->or_where($Inarr)->or_where($Outarr)->limit($ulimit, $olimit)->get();

//--------Syntax problem------------------------------------------//
$whereSQL=" (status='Op' and userID='".$userId."') or (status='R' and fUserID='".$userId."') ";
$whereSQL=$whereSQL." or (status='OC' and userID='".$userId."') or (status='C' and fUserID='".$userId."') ";

$query=$this->db->from('message')->where($whereSQL)->get();
Reply


Messages In This Thread
sql return all rows - by rchiu5hk - 09-09-2015, 09:21 AM
RE: sql return all rows - by mwhitney - 09-09-2015, 09:31 AM
RE: sql return all rows - by Wouter60 - 09-09-2015, 11:45 AM
RE: sql return all rows - by rchiu5hk - 09-09-2015, 03:58 PM
RE: sql return all rows - by mwhitney - 09-10-2015, 07:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB