CodeIgniter adds row to table name
In my CodeIgniter project, I have separate tables for each user. for example tbl_user1, tbl_user2, tbl_user3, tbl_user4, etc., these 1,2,3,4 are user IDs.
after the user is logged in, I need to access the table that is associated with the user. (for example, for user 2, you need to get data from the tbl_user2 table).
I have a session variable containing a user id,
$uid=$this->session->userdata('uid'); //$uid=2 for **user 2**
how to use this with my model and controller,
ex. controller
$this->tbl_user('username'); //$this->tbl_user.$uid('username');
- does not work
ex. model
$this->db->select('tbl_user.$uid.*', false); - //not working
$this->db->from('tbl_user.$uid'); - //not working
please advise.
+3
source to share