更新时间:2023-12-03 16:35:52
您可以使用离子授权中的 get_user_id()
函数来获取用户ID。在模型中的相关注释中,您需要一个 $ this-> db-> from()
调用来设置表以获取行数。
Provided the user is logged in you can get the user ID by using the get_user_id()
function in ion auth. On a related note in your model you need a $this->db->from()
call to set the table to fetch the number of rows from.
public function total_open_wo() {
$userId = $this->ion_auth->get_user_id();
$this->db->where('status', '1');
$this->db->where('tid', $userId);
$this->db->from('work_orders');
$num = $this->db->count_all_results();
return $num;
}
使用函数 $ this-> ion_auth- > logged_in()
以确保用户在调用模型函数之前已登录。
Use the function $this->ion_auth->logged_in()
to make sure that the user is logged in before calling the model function.