multi domain different db prefix |
[eluser]egoslip[/eluser]
Hey guys im trying to rack my brain here and cant figure out the "CORRECT" way of doing this. I have a db table that has each domain with and id IE: |id|dname |1 |foo.com |2 |bar.com |3 |foobar.com what i want to do is if they land on foo.com it would it would add a prefix tag to select tables so it can be 1_pages 2_pages 3_pages ...etc and each table would pull the correct data depending on the current domain name. But still be able to access the core tables like "users"
[eluser]tomcode[/eluser]
Take the base_url(), eventually clean it from subdomains(www, etc). Fetch Your id. Query Your table. Where is the problem ? Why don't You have just one table with a field containing the domain id / or directly the domain ? Unless You will not have thousands of pages ...
[eluser]egoslip[/eluser]
ahh for some reason it didnt post the rest of my post mmm... Well the rest of it was how can i change the db_prefix settings per controller i dont want to change the config file and i dont want to edit all that tables in my model ... this way i can just tag a bit of code at the top of select controllers and change the db prefix just for them ...
[eluser]tomcode[/eluser]
You can solve that by connecting to multiple databases, see the user guide http://ellislab.com/codeigniter/user-gui...cting.html, then You can access the domaon specific database and the common database at the same time. I guess that's what You want and now I better unerstand what You try to do
[eluser]egoslip[/eluser]
ya kinda what i need but I would like to keep everything in one database I just want to change the db prefix per controller something like what i have below $this->site =1 //domain index $this->CI =& get_instance(); $this->CI->db->dbprefix=$this->CI->db->dbprefix.$this->site.'_'; it changes it for the whole site but I only want it to change for the current model like how can I get the current prefix then set the new modified prefix to the current model only.. Sorry for the confusing posts i cant seem to explain i like to do
[eluser]tomcode[/eluser]
Well You could simply create Your own prefix variable which You use every time You query a domain specific table. |
Welcome Guest, Not a member yet? Register Sign In |