dbprefix does not work with joins |
Hi Folks,
I have created two tables in my database called company_db cp_branches cp_emp I have set dbprefix as cp_ in config > database.php when I run the following query, I get Table 'company_db.emp' doesn't exist error. PHP Code: $this->db->start_cache(); Error Number: 1146 Table 'company_db.emp' doesn't exist SELECT bran_id, bran_name, bran_abbreviation, bran_mobile, bran_phone, bran_email, bran_status, bran_order_by, bran_added_date, concat(emp_fname, " ", emp_lname) as emp_name FROM `cp_branches` LEFT JOIN emp as e ON e.emp_id = branches.bran_added_by ORDER BY `bran_order_by` DESC dbprefix is not added to table names in join function. Am I missing anything here? Same code works fine in Codeigniter 2.x.
The db prefix is added while escaping the query, so passing false as the 4th argument to $this->db->join() is preventing the addition of the prefix. You couldn't prevent Active Record from escaping a join clause, so this argument didn't exist in CI 2.x.
|
Welcome Guest, Not a member yet? Register Sign In |