Hi i got a problem with a query with CodeIgniter 3.
I'm trying to get all users from database with limit and start excluding the ID of the user who is getting the list.
That's my model:
public function getUserList($id,$limit,$start){
$this->db->select('*');
$this->db->from('register');
$this->db->where('register.id' != $id);
$this->db->order_by("id");
$this->db->limit($limit,$start);
$result = $this->db->get();
return $result->result_array();
}
And that's the controller:
public function users(){
$this->load->model('User_model');
$id = $_GET['id'];
$limit = $_GET['limit'];
$start = $_GET['start'];
$data = $this->User_model->getUserList($id,$limit,$start);
echo "<pre>"; print_r($data); die;
$this->load->view('api', $data);
}
The problem is this function return me an empty array instead an array of 5 array.
Custom key/value method:
You can include an operator in the first parameter in order to control the comparison:
Change below line.
$this->db->where('register.id !=', $id);