这是我的代码:
我的模型:My_model
function load_modules(){
$modules = $this->db->query('SELECT name FROM module');
$result = $modules->result_array();
return $result;
}
function load_lesson($modname){
$lessons = $this->db->query(
'SELECT lesson.name
FROM lesson
INNER JOIN module
ON module.id = lesson.moduleid and module.name = $modname'
);
$result = $lessons->result_array();
return $result;
}
我的控制器:My_controller
$this->load->model('My_model');
$arraydata['values'] = $this->My_model->load_modules();
在我看来:
foreach($values as $modulename){
load_lesson($modulename); // This is the method from my model which
// I want to be access in my controller in a way that will work like this.
}
我想要发生的是能够获得每个模块的所有课程。但我想不出在控制器中做到这一点的方法。希望你能帮我解决这个问题。谢谢!