下面的查询在我的codeigniter项目中使用并且只给我一条记录,但是当我在数据库中调用此查询并给我3条记录时。
$query = "SELECT `teacher_subjects`.*, `subjects`.* FROM `teacher_subjects` JOIN `subjects` ON `subjects`.`id` = `teacher_subjects`.`subject_id` WHERE `teacher_subjects`.`session_id` = 11 AND `teacher_subjects`.`class_section_id` = 5";
$query = $this->db->query($query);
答案 0 :(得分:0)
试试这个,
$query_statement = "SELECT `teacher_subjects`.*, `subjects`.* FROM `teacher_subjects` JOIN `subjects` ON `subjects`.`id` = `teacher_subjects`.`subject_id` WHERE `teacher_subjects`.`session_id` = 11 AND `teacher_subjects`.`class_section_id` = 5";
$query = $this->db->query($query_statement);
return ($query->num_rows() > 0) ? $query->result() : false;