如何使用 codeigniter 中的会话 ID 从 table 检索数据

How to retrieve data from a table using session id in codeigniter

你能帮我做一下codeignor吗?

$admin_id = $this->session->userdata('admin_id');

使用此 admin_id 从 user_table

中获取 roll_id

[user_table][1]

你能告诉我使用这个 roll_id 在 roll_details table 中获取 roll_name 的查询吗?

[role_details][2]

我的尝试

$admin_id = $this->session->userdata('admin_id'); 
$profile_info = $this->db->where('admin_id', $admin_id)
                     ->get('usertable')
                     ->row()
                     ->role_id
                   



  [1]: https://i.stack.imgur.com/fQaYO.jpg
  [2]: https://i.stack.imgur.com/m1wGt.jpg




I am getting roll_id

Can data be extracted from the roll_details table using that roll id?
$this->db->select('*');
$this->db->from('role_details');
$this->db->join('user_table', 'user_table.roll_id = role_details.id');
$this->db->where('user_table.admin_id', $admin_id);

$query = $this->db->get();
$data = $query->result_array();
echo '<pre>';print_r($data);