I am trying to compare the variable $manager_id is present in pr_resignation_requests as managerid column. If present then return the row else dont. But somehow this query is not working. Tried many things but doesn't work. I know my where clause has the error,
Error is :
Error Number: 1054
Unknown column '1' in 'where clause'
SELECT g.*, userids, resignations_date, reason_type, requested_date, last_status, date_last_status, agreed_date, exit_details, exit_checklist, firstname, lastname, managerid FROM (pr_resignation_requests as g) JOIN pr_users_details as ud ON ud.userid = g.userids WHERE
1= 'managerid'
My query is :
function get_resignation_request($id=0)
{
global $USER;
$post_arr = $this->input->post();
$manager_id = $this->get_value_by_id('managerid','users',$this->session->userdata('admin_id'));
$this->db->select('g.*,userids,resignations_date,reason_type,requested_date,last_status,date_last_status,agreed_date,exit_details,exit_checklist,firstname,lastname,managerid');
$this->db->from('pr_resignation_requests as g');
$this->db->where($manager_id, managerid);
//$where = "$manager_id='1'";
//$this->db->where($where);
//$this->db->join('pr_resignation_requests as uds','uds.managerid = ".$manager_id" ');
//$this->db->where($manager_id, managerid);
//$this->db->where($manager_id = managerid);
//$this->db->join($this->myTables['pr_users_details'].' as ud','ud.userid = g.userid');
$this->db->join('pr_users_details as ud','ud.userid = g.userids');
//$this->db->join('pr_users as uds','uds.id = g.managerid');
/*$this->db->join('pr_resignation_type as gt','gt.id = g.sr_type');*/
$query=$this->db->get();
$return = $query->result_array();
return $return;
}
Your query is wrong. In where clause first parameter is table name not the value
$query = $this->db->where('managerid', $manager_id);