我有以下型號:笨:如何從模型到控制器發出陣,然後查看
// Session info in $session array.
$session = $query->row_array();
$userid = $session['uid'];
$uq = $this->db->query("SELECT * FROM `administration_users` WHERE id = $userid");
$now = strtotime(date("m/d/Y h:i:s A"));
if($session['terminatedate'] > $now) {
// If Session is STILL ACTIVE, let's give them an additional hour. Have fun!
$newterm = $now + 3600;
$userq = $uq->row_array();
$username = $userq['username'];
$userfull = $userq['name_first'] . " " . $userq['name_last'];
$this->ELog->authentication('INFORMATION',$username,"Session for $userfull has been extended by 3600 seconds (1 hour) due to activity in application.");
$this->db->query("UPDATE `administration_sessionkeys` SET terminatedate='$newterm' WHERE id='$session[id]'");
} elseif($session['terminatedate'] < $now) {
// If Session is OVER...
$userq = $uq->row_array();
$username = $userq['username'];
$userfull = $userq['name_first'] . " " . $userq['name_last'];
$this->ELog->authentication('INFORMATION',$username,"$userfull has been logged out automatically by AuthLogger due to session timeout. Thanks for stopping by. Goodbye!");
$this->db->query("UPDATE `administration_sessionkeys` SET `terminated`='1',`terminated_details`='Session Ended. Thanks for stopping by. Goodbye!' WHERE id='$session[id]'");
setcookie("ssmp_auth_cookie_uid", "", time() - 3600);
return false;
}
$userinfo[] = $uq->row_array();
return array($userinfo);
我的控制器,看起來是這樣的:
$this->load->model('Auth_model', "", TRUE);
$data = array($this->Auth_model->authcheck());
if(!$data) {
header("Location: /auth/login");
} else {
$this->load->view('tmpl/header', $data);
$this->load->view('dashboard', $data);
$this->load->view('tmpl/footer', $data);
}
我的看法是這樣的,和這裏的問題是我無法從視圖中的模型訪問我的數組。我究竟做錯了什麼?現在我已經在我的腦子上打了3個小時了。我需要休息和一些幫助。
<title>Logged into SSMP as <?=$id;?></title>
這應該給我陣列中的「id」列,對吧?沒有?
請在這裏幫助我,很抱歉這麼多的代碼,我不確定你們需要看到什麼來幫助我。
感謝所有能夠提供援助這個令人煩惱的問題。
斯科特
首先確保您有'$ data'數據,用'的print_r檢查($數據)' –