嗨,我在创建的库文件夹中的函数遇到了一个小问题。我似乎无法获得用户 ID。不确定如果我使用坦克身份验证应该是什么?
我使用代码点火器和坦克身份验证。
function getAuthorName($id) {
$ci =& get_instance();
$ci->db->select()->from('users')->where('id', $user_id);
$result = $ci->db->get()->result_array();
return $result[0]['username'];
}
function getAuthorAvatar($id){
$ci =& get_instance();
$ci->db->select()->from('users')->where('id', $user_id);
$result = $ci->db->get()->result_array();
return $result[0]['avatar_link'];
}
您的 where 子句中有一个错误。 尝试:
$ci->db->select()->from('users')->where('id', $id);