I have a simple CodeIgniter Active record query to select an ID:
$q = $this -> db
-> select(\'id\')
-> where(\'email\', $email
public function getSalary()
{
$this->db->select('tbl_salary.*,tbl_employee.empFirstName');
$this->db->from('tbl_salary');
$this->db->join('tbl_employee','tbl_employee.empID = strong texttbl_salary.salEmpID');
$this->db->where('tbl_salary.status',0);
$query = $this->db->get();
return $query->result();
}
function news_get_by_id ( $news_id )
{
$this->db->select('*');
$this->db->select("DATE_FORMAT( date, '%d.%m.%Y' ) as date_human", FALSE );
$this->db->select("DATE_FORMAT( date, '%H:%i') as time_human", FALSE );
$this->db->from('news');
$this->db->where('news_id', $news_id );
$query = $this->db->get();
if ( $query->num_rows() > 0 )
{
$row = $query->row_array();
return $row;
}
}
This
echo $this->db->select('title, content, date')->get_compiled_select();
This is your code
$q = $this -> db
-> select('id')
-> where('email', $email)
-> limit(1)
-> get('users');
Try this
$id = $q->result()[0]->id;
or this one, it's simpler
$id = $q->row()->id;