我的 Controller 代码
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);
}
我的模型代码(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();
}
结果
发生数据库错误
错误号:1054
“where 子句”中的未知列“数组”
从tbl_customer
中选择*,其中id
= 数组
文件名:C:/wamp64/www/theme/system/database/DB_driver.php
行号:691
大家好,我是 codeignitor 的新手。我想从上表中检索数组的每个值的记录。但是发生了错误。请帮助我。
注意:数据库、表定义在模型页面顶部
最佳答案
尝试使用 where_in
方法,因为您为条件提供 $first_names
数组:
$this->db->where_in('id', $first_names);
关于mysql - 通过传递数组从数据库中检索记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49340904/