1 回答

TA貢獻1886條經(jīng)驗 獲得超2個贊
快速檢查$user中的內(nèi)容Ion_auth_model.php、set_session() 正在使用 var_dump 顯示它是...
LINE: 1944 Module Ion_auth_model
object(stdClass)#26 (5) {
["email"]=>
string(21) "frednurk@gmail.com"
["id"]=>
string(1) "8"
["password"]=>
string(60) "$2y$10$MGlESdMfrr/UNd.mdW4Vr.nyTqES0SB6rEnaDBOYocwU7yLXVqNMq"
["active"]=>
string(1) "1"
["last_login"]=>
string(10) "1599322333"
}
不包含first_name。由于錯誤消息,這正是您所期望的。
搜索調(diào)用此函數(shù)的位置,將帶您返回 Ion_auth_model.php - 登錄,其中 $user 的選擇查詢是
$query = $this->db->select($this->identity_column . ', email, id, password, active, last_login')
->where($this->identity_column, $identity)
->limit(1)
->order_by('id', 'desc')
->get($this->tables['users']);
正如預(yù)期的那樣,它丟失了first_name。
因此,將first_name 添加到選擇中,如下所示...
$query = $this->db->select($this->identity_column . ', email, id, password, active, last_login, first_name')
->where($this->identity_column, $identity)
->limit(1)
->order_by('id', 'desc')
->get($this->tables['users']);
結(jié)果 $user 變成...
LINE: 1944 Module Ion_auth_model
object(stdClass)#26 (6) {
["email"]=>
string(21) "frednurk@gmail.com"
["id"]=>
string(1) "8"
["password"]=>
string(60) "$2y$10$MGlESdMfrr/UNd.mdW4Vr.nyTqES0SB6rEnaDBOYocwU7yLXVqNMq"
["active"]=>
string(1) "1"
["last_login"]=>
string(10) "1599322333"
["first_name"]=>
string(3) "Tim"
}
然后就一切皆大歡喜了。
結(jié)論
閱讀錯誤消息
通過檢查變量/數(shù)組/對象來查看它們是什么來執(zhí)行調(diào)試。
回來修復(fù)它。
調(diào)試時,我使用了這個小代碼片段
echo '<pre>';
echo 'LINE: '. __LINE__. ' Module '.__CLASS__.'<br>';
var_dump(WHAT_TO_LOOK_AT_GOES_HERE);
echo '</pre>';
- 1 回答
- 0 關(guān)注
- 175 瀏覽
添加回答
舉報