我在 View 顶部收到此错误(即使 View 按预期正确加载了数据)
遇到 PHP 错误
Severity: Warning Message: Illegal offset type Filename: database/DB_query_builder.php Backtrace:
File: C:\wamp64\www\procurement_v_alpha1\application\models\Notifications.php Line: 32 Function: where
我的模型看起来像,
public function user_alert ()
{
$session_data = $this->session->userdata['logged_in'];
$role = $session_data['role'];
$dept = $session_data['dept'];
$data_user = array(
'role' => $role,
'dept' => $dept
);
$role = $data_user['role'];
$this->db->from('notification');
$this->db->select('pr_id,item_name,dept_division');
$this->db->where($role, 0);
$query = $this->db->get();
return $query -> result_array();
}
你们能帮我解决这个问题吗? 使用“where”方法有问题吗?
最佳答案
如果您尝试访问的项目不存在,则 userdata() 方法将返回 NULL。可以这样吗?也许您必须添加一些 isnull 检查。
关于php - 警告消息来自Where函数Mysql php的非法偏移类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47765693/