Reputation: 39
My controller code
public function all_ratings(){
$result_ratings = $data['result_ratings'] ;
**(I have successfully captured '$result_ratings' data here)**
$first_names = array_column($result_ratings, 'customer_id');
$data['result_cus'] =$this->mod_customers->get_unique_customer($first_names);
//var_dump($data['result_cus']); die();
data['related_view']='system_rating_appointments';
$this->load->view('template', $data);
}
My model code(mod_customers)
public function get_unique_customer($first_names){
$this->load->database();
$this->db->where('id', $first_names);
$query = $this->db->get($this->table);
return $query->result_array();
}
Result
A Database Error Occurred
Error Number: 1054
Unknown column 'Array' in 'where clause'
SELECT * FROM tbl_customer
WHERE id
= Array
Filename: C:/wamp64/www/theme/system/database/DB_driver.php
Line Number: 691
Hi all,I'm new to codeignitor.I want to retrieve records for each value of the array from the above table.But error occurred.Please help me.
Note : database,table defined on top of the model page
Upvotes: 0
Views: 36
Reputation: 4719
Try using where_in
method as you are supplying array of $first_names
for the condition :
$this->db->where_in('id', $first_names);
Upvotes: 1