Reputation: 5784
What is the right way to get all the data from the 'users' table in my database, using Tank Auth?
I tried it with just with $this->db->get('users');
But how do i get the data for the specific logged-in user?
Do I have to use $this->tank_auth->get_user_id();
?
Here's what I've tried:
function get_user_data()
{
$id = $this->tank_auth->get_user_id();
$this->db->where('id', $id);
$users = $this->db->get('users');
return $users->result();
}
I hope somebody can help me out with this.
Upvotes: 0
Views: 276
Reputation: 3740
This code will get data about the current logged user.
In your controller:
$this->load->library('tank_auth');
if (!$this->tank_auth->is_logged_in()) {
exit('no logged user');
} else {
$user_id = $this->tank_auth->get_user_id();
$user_data = $this->users->get_user_by_id($user_id,1);
}
Upvotes: 1