我的模型中具有以下功能,可以根据会话中的用户 ID 选择记录。
public function getOfficer()
{
$usr = $this->session->userdata('id_user');
$userArray = $this->db->order_by('last_name','ASC')->where_in('tbl_officer.p_code', [8,10,24]);
$userArray1 = $this->db->order_by('last_name','ASC')->get_where('tbl_officer', array('status' => 1, 'usr'=>$this->session->userdata('id_user')));
if($usr == 4){
$this->db->where('p_code',$userArray );
}else{
$this->db->where('usr',$userArray1);
}
$q = $this->db->get('tbl_officer');
if ($q->num_rows() > 0) {
return $q->result();
}
return false;
}
如果会话中的用户 4,则应按 p_code [8,10,24] 和会话中的任何其他用户来筛选记录,则应按 usr 筛选记录。usr 列包括用户 ID,如 1,2,3,4 等。
但是该函数在错误后退出,并且没有得到预期的结果。
错误编号:42000/1064
您的 SQL 语法中存在错误;查看与您的 MariaDB 服务器版本对应的手册,了解在第 2 行的“WHERE =”附近使用的正确语法p_code
选择 * 其中p_code =
文件名:C:/xampp/htdocs/doahrm/application/models/Officer_model.php
行号: 106
函数中包含第 106 行。$q = $this->db->get();
可能出了什么问题?任何人都可以帮忙吗?
海绵宝宝撒