2017-04-23 44 views
-1

ORDER BY不起作用。我嘗試過我知道的方式,但它不會排序,爲什麼?排序不工作Codeigniter

回報:調用一個成員函數result_array()上布爾

public function getDetailbyClsandSection($class_id, $section_id, $exam_id) { 
    $query = $this->db->query("SELECT exam_schedules.*,subjects.name,subjects.type FROM exam_schedules,teacher_subjects,exams,class_sections,subjects WHERE exam_schedules.teacher_subject_id = teacher_subjects.id and exam_schedules.exam_id =exams.id and class_sections.id =teacher_subjects.class_section_id and teacher_subjects.subject_id=subjects.id and class_sections.class_id =" . $this->db->escape($class_id) . " and class_sections.section_id=" . $this->db->escape($section_id) . " and exam_id =" . $this->db->escape($exam_id) . " and exam_schedules.session_id=" . $this->db->escape($this->current_session));  
    return $query->result_array(); 
} 
+0

500錯誤是服務器錯誤,而不是MySQL的。你可能犯了一些語法錯誤。 – learner

+0

@learner有什麼辦法呢? –

+0

@learner當沒有任何語法錯誤存在時它仍然不起作用 –

回答

0
$query = $this->db->query("SELECT exam_schedules.*,subjects.name,subjects.type FROM exam_schedules,teacher_subjects,exams,class_sections,subjects WHERE exam_schedules.hide = 'N' and exam_schedules.teacher_subject_id = teacher_subjects.id and exam_schedules.exam_id =exams.id and class_sections.id =teacher_subjects.class_section_id and teacher_subjects.subject_id=subjects.id and class_sections.class_id =" . $this->db->escape($class_id) . " and class_sections.section_id=" . $this->db->escape($section_id) . " and exam_id =" . $this->db->escape($exam_id) . " and exam_schedules.session_id=" . $this->db->escape($this->current_session) . " ORDER BY exam_schedules.date_of_exam ASC"); 
+0

現在工作 –