Вложеный запрос в codeignator
Как всегда мало водного текста, сразу код, ниже немного разъяснения по нему $this->db->select("*") ->from("schedule") ->order_by("schedule.dayofweek", "asc") ->order_by("schedule.lesson_number", "asc") ->order_by("date_approve", "desc"); $s = $this->db->_compile_select(); $this->db->_reset_select(); $dbprefix = $this->db->dbprefix; $this->db->set_dbprefix(''); $this->db->select("*") ->from('(' . $s . ') as ' . $this->db->dbprefix . 'schedule_tmp'); $this->db->set_dbprefix($dbprefix); $this->db->join("lessons", "lessons.lesson_id = schedule_tmp.lesson_id", "left") ->join("students", "schedule_tmp.class_id = students.class_id") ->where("schedule_tmp.class_id", $class_id) ->where("schedule_tmp.date_approve