0
我有Model_User怎樣的foreach模型意見fuelphp
// Get Exams by User
public static function get_exam_by_user($user_id) {
$query = "SELECT e.exam_id, e.exam_code, e.exam_name, e.description, e.creator, e.password,
e.max_attempt, e.random_order, e.max_time, e.max_score, e.min_score, e.grading,
e.created_at, e.updated_at
FROM exam e, user_exam ue
WHERE ue.exam_id = e.exam_id
AND ue.status = 1
AND ue.user_id = :user_id";
$result = DB::query($query)->bind('user_id', $user_id)->execute();
return $result->as_array();
}
與此控制器
public function action_index() {
$data = array();
//$data['user_id'] = \Auth\Auth::get('id');
//$data['username'] = \Auth\Auth::get('username');
$user_id = Auth\Auth::get('id');
//$data['exams'] = Model_Exam::find('all');
$data['exams'] = Model_Exam::get_exam_by_user($user_id);
$this->template->title = "Exams";
$this->template->content = View::forge('admin/exam/index', $data);
}
如何的foreach到的意見?我嘗試printr_r
Array ([0] => Array ([exam_id] => 2 [exam_code] => SD_K1S1_MAT [exam_name] => Ujian Matematika SD Kelas 1 Sem 1 [description] => [creator] => RF [password] => [max_attempt] => 3 [random_order] => 1 [max_time] => 60 [max_score] => 100 [min_score] => 0 [grading] => [created_at] => 2013 [updated_at] => 2013) [1] => Array ([exam_id] => 2 [exam_code] => SD_K1S1_MAT [exam_name] => Ujian Matematika SD Kelas 1 Sem 1 [description] => [creator] => RF [password] => [max_attempt] => 3 [random_order] => 1 [max_time] => 60 [max_score] => 100 [min_score] => 0 [grading] => [created_at] => 2013 [updated_at] => 2013))
,如果你可以幫助解決這個問題
好的謝謝:)它的工作 – avew
好吧,我會很高興,如果你也接受(up-vote)的答案太:) – mgm
看起來像一個'撞擊和奔跑'的問題在這裏,我upvoted你一個努力。 – Klaaz