I submitted a ticket.
https://trac.cakephp.org/ticket/4873
Sorry for it not being very clear, it was my first one. I try to build
a test case but I don't know yet how to use multiple database configs
in a test case.
Any help would be appreciated (even telling me I'm a complete fool
would be)
Guillaume
On 9 juin, 08:19, Guillaume <[EMAIL PROTECTED]> wrote:
> Hello,
> I don't have time to test if deeper now (going to work!) but I
> encountered strange problems with a Shell script using Models
> belonging to different databases.
> My Shell script aims at migrating data from an old database named
> "popnews_old" to a new one named "popnews" so it uses models belonging
> to different databases.
>
> $this->Model->find('all') with a Model pointing toward the old
> database issues a query to the wrong database.
>
> It used to work perfectly before.
>
> Here are some excerpts of my code :
>
> //{app}/config/database.php
> var $default = array('driver' => 'mysql',
> 'connect' =>
> 'mysql_connect',
> 'host' =>
> '127.0.0.1',
> 'login' =>
> 'xxxxxx',
> 'password' =>
> 'xxxxx',
> 'database' =>
> 'popnews',
> 'prefix' =>
> '',
> 'port' =>
> 8889);
>
> var $oldLocalDatabase = array('driver' => 'mysql',
> 'connect' =>
> 'mysql_connect',
> 'host' => '127.0.0.1',
> 'port' => 8889,
> 'login' => 'xxxxxxxx',
> 'password' => 'xxxxx',
> 'database' =>
> 'popnews_old',
> 'prefix' => '');
>
> //{app}/models/old_redacteur.php
>
> class OldRedacteur extends AppModel {
>
> var $name = 'OldRedacteur';
>
> var $useDbConfig = 'oldLocalDatabase';
>
> var $useTable = 'REDACTEURS';
>
> var $primaryKey = 'REDID';
>
> }
>
> //{app}/vendors/shells/recup_users.php
> class RecupUsersShell extends Shell {
> var $uses = array ('OldRedacteur', 'User');
> var $tasks = array('DbConfig');
>
> function main($rundry = false) {
> // this line outputs the right db config !
> $this->out('db config '.$this->OldRedacteur->useDbConfig);
>
> // this line doesn't work anymore
> $redacteurs = $this->OldRedacteur->find('all');
> ...
>
> The last line generates this error :
> the query (with the good fields from the table the model relates to) +
> <b>SQL Error:</b> 1146: Table 'popnews.REDACTEURS' doesn't exist</
> span>
> which indicates that the query is executed on the wrong database
> ("popnews" and not "popnews_old").
>
> I don't have the time to fill in a ticket for the moment, but does
> someone have this strange problem?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---