我將一個數組傳遞給我的模型,我想獲取不在該數組中的employee_id。 '位置'字段也應該等於'c'。codeigniter where_not_in不工作
以下是我的表:
以下是我的模型。 $ evdata是傳遞給模型以限制選擇記錄的數字。數組$ data也是json編碼的數組。
公共職能get_camaramens($數據,$ evdata) {
$this->db->select('emp_position.employee_id');
$this->db->from('emp_position');
$this->db->where('emp_position.position','c');
$this->db->where_not_in('emp_position.employee_id',$data);
$query=$this->db->get('',$evdata);
return $query->result();
}
它沒有給予正確的結果。所以我刪除了以下部分並進行了檢查。
$this->db->where_not_in('emp_position.employee_id',$data);
這兩次都給出了相同的結果。這似乎只是第一個條件工作的地方。
以下是兩個時代的var_dump結果:
添加代碼
$data = $this->emp_event_model->get_current_employees($date);
$newData = array();
foreach($data as $row) {
$newData[] = $row['employee_id'];
}
$data = $newData;
後,給出了這樣的錯誤:
可你'的var_dump($的數據); '看看'$ data'的結果怎麼樣? – Beginner
array(size = 5)
0 => 對象(stdClass的)[26] 公共 'EMPLOYEE_ID'=>字符串 '2'(長度= 1) 1 => 對象(stdClass的)[27] 公共 'EMPLOYEE_ID'=>字符串「3 '(長度= 1) 2 => 對象(stdClass的)[28] 公共 'EMPLOYEE_ID'=>字符串 '7'(長度= 1) 3 => 對象(stdClass的)[29] 公共' EMPLOYEE_ID '=> string'8'(length = 1) 4 => object(stdClass)[30] public'employee_id'=> string'9'(length = 1) – Christeen
你是$ data數組必須在'array(1,2,3)'format not'array('employee_id'=> 1,'employee_id'=> 2,等等......)' – Beginner