Reputation: 922
I am trying to get a result_array()
from a database which two columns must return true, and vise-versa so I decided to use or_where
but my code is returning Call to undefined method CI_DB_mysqli_result::or_where()
error, any advice how can achieve this?
I am using below code on inside my CI_Model.
public function check_request($userid, $senderid){
$query = $this->db->get_where('connection',array('user_id' => $userid, 'sender_id' => $senderid));
$query = $this->db->or_where('connection',array('sender_id' => $userid, 'user_id' => $senderid));
return $query->result_array();
}
Upvotes: 1
Views: 1161
Reputation: 3540
Try the Below:
public function check_request($userid, $senderid){
$this->db->select('*');
$this->db->where("(user_id = '$userid' AND sender_id = '$senderid')
OR (sender_id='$userid' AND user_id = '$senderid')");
$query = $this->db->get('connection');
return $query->result_array();
}
Upvotes: 1
Reputation: 492
You can try it like this. Before some day same issue i got. and i had try like this.
$query = $this->db->select('*')
->where("(user_id = '$userid' AND sender_id = '$senderid') OR (user_id = '$senderid' AND sender_id = '$userid')")
->get('connection');
return $query->result_array();
Upvotes: 1