我正在尝试使用 CodeIgniter activercord 类进行连接查询,如下所示:
$query = $this->db->select('accredited_majors, all_majors_accredited, accredited')
->select('universities.name, universities.slug')
->from('accreditations')
->join('universities', 'universities.id = '.$uni_id)
->where('accreditations.university_id', $uni_id)
->where('accreditations.country', $country)
->get();
但我收到这个错误:
A Database Error Occurred
Error Number: 1054
Unknown column '820' in 'on clause'
SELECT `accredited_majors`, `all_majors_accredited`, `accredited`, `default_universities`.`name`, `default_universities`.`slug` FROM (`default_accreditations`) JOIN `default_universities` ON `default_universities`.`id` = `820` WHERE `default_accreditations`.`university_id` = '820' AND `default_accreditations`.`country` = 'AE'
我相信错误出现在 join() 行中:
->join('universities', 'universities.id = '.$uni_id)
如何在 join() 函数中包含变量?