EllisLab text mark
Advanced Search
     
DBPrefix
Posted: 09 October 2012 04:23 PM   [ Ignore ]
Joined: 2012-08-08
18 posts

I’ll be having two different CodeIgniter installations sharing the same database but different tables.  Is this a situation where you would want to use the dbprefix property when configuring database connections?  From my understanding dbprefix prepends a string to each table name when running queries.  Is the point of this simply to shorten code rather than saying app1_tablename, app2_tablename, etc. or is there a stronger purpose.

My idea was just to prefix each table name manually when creating them in MySQL like app1_users, app2_users, etc.

What would be the best way to go about this?  I guess I’m just not understanding the purpose of dbprefix when I can take care of it self.

 
Posted: 09 October 2012 08:38 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2007-11-28
2435 posts

It’s just a tool to make your life easier, if you want to use it. It does exactly that - adds the prefix to table names. Don’t over think about what its “intended” purpose might be. In some situations, prefixes help if there is a potential conflict in table names.

Note that it’s only for active record, and will not affect using $this->db->query() manually. But yeah, it’s up to you if you want to use it or not.