Welcome Guest, Not a member yet? Register   Sign In
when to use dbprefix
#1

[eluser]bientek[/eluser]
If I want two CI installations to share a table in the same database, should I use dbprefix?

The CI manual refers to dbprefix as
Quote:"An optional table prefix which will added to the table name when running Active Record queries. This permits multiple CodeIgniter installations to share one database."

I am hoping that someone might be able to elaborate on when it is and isn't appropriate to set dbprefix. It appears that multiple CI installations can already access the same DB using the same shared credentials, and I don't know if setting dbprefix is appropriate when multiple CI projects are sharing a table in a DB. My background on MySQL is a bit weak, so this may be the root of my confusion.
#2

[eluser]WanWizard[/eluser]
The idea behind a prefix is that you can have multiple application (not only CI applications) use the same database. So all tables of App1 will be prefixed with "app1_", and all tables of App2 with "app2_".

That is completely different then two CI installation using the same table. In that case, assuming that the prefix for that table is different then the default prefix for the application, define a second database group in your database.php setup for the same database but with the other prefix, and use that to access the shared table. Check "Connecting to multiple databases" on http://ellislab.com/codeigniter/user-gui...cting.html.
#3

[eluser]bientek[/eluser]
Thanks for the reply. I did not follow you very well, but it sounds like I should not use dbprefix if I want multiple apps sharing the same data (same DB, same table).




Theme © iAndrew 2016 - Forum software by © MyBB