I need some help with some models and table prefix.
Here is my scenario:
I have 2 controllers:
controller1 and controller2.
controller1 use table prefix c1_ and controller2 use table prefix c2_
and I have some comon tables too, without prefix, accessed by $default config.
But the specific tables have the same name, for controller1 and controller2...
so, my database is like this:
clients
configs
c1_configs
c1_data
c1_users
c2_configs
c2_data
c2_users
Actually, Im trying to put 2 old systems to work together for a client.
It need to be at same database, thats why I used the table prefix.
Each system is already working alone, with or without table prefix.
My first problem is:
1. The both controllers are accessing the models, that have the same name. But now I need to put the table prefix. So, how do I keep the same name of the Model for both controllers? Ex.: I have the model file config.php, and I can use it on controller1, setting the table prefix to c1_, and then I can access this model on controller1 with $this->Config. How can I keep the $this->Config on controller2 too? So I wont need to search the whole code to change just this.
Ps.: In some models, I use the var $useTable. Could this cause any problem with table prefix or cake takes this var and adds the prefix to access the table?
My second problem:
2. How do I use 2 diferent database configurations on the same controller? Ex.: I have to access the configs table AND the c1_configs table in controller1.
So, I need to use 2 diferent db configs.
This one doesnt need to have the same name, 'cause I will create this functions yet. But I need to use some tables without prefix AND other tables with prefix in the same controller.
Do I have to create one model for table configs and one model for table c1_configs?
I already tried all that stuff found at google to change database config on the fly, but it didnt work.
Im getting confused.
Can anyone help me?
Thank you!
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment