This is a known issue.
In your connections in database.php add
the clause 'persistent' => false like in this example:
class DATABASE_CONFIG {
var $global = array(
'driver' => 'mysql',
'connect' => 'mysql_connect',
'host' => 'localhost',
'login' => '*******',
'password' => '*******',
'database' => 'global',
'persistent' => false, // <=========
'prefix' => ''
);
var $en = array(
'driver' => 'mysql',
'connect' => 'mysql_connect',
'host' => 'localhost',
'login' => '*******',
'password' => '*******',
'database' => 'en',
'persistent' => false, // <=========
'prefix' => ''
);
}
If this does not work you need separate login passwords for each database.
HTH
> -----Messaggio originale-----
> Da: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Per conto di cloud
> Inviato: sabato 14 aprile 2007 7.02
> A: Cake PHP
> Oggetto: Re: accessing different database from a controller
>
>
> Dear Joshua,
>
> They are all mysql tables and residing in a same server.
> I did some more testing and found that if I changed the $uses in the
> sites_controller.php:
> from :
> class SitesController extends AppController {
> var $name = 'Sites';
> var $uses = array('Site' , 'Language'); }
>
> to become :
> class SitesController extends AppController {
> var $name = 'Sites';
> var $uses = array('Language', 'Site' ); }
>
> Then now it change: I can access the Site but can't access
> the Language model.
> It seems that only the latter model (database) mentioned in
> the $uses is being used.
>
> Please advise.
> Thank you.
>
>
>
> On Apr 14, 8:41 am, "Joshua Benner" <[EMAIL PROTECTED]> wrote:
> > Are they entirely different database backends? What type of
> databases
> > are they?
> >
> > On Apr 13, 2:24 pm, "cloud" <[EMAIL PROTECTED]> wrote:
> >
> > > Dear all,
> >
> > > I just started using CakePHP for developing my company website.
> > > Have searched the forum, but couldn't find any info.
> >
> > > Need to acces 2 tables which located in 2 different
> database from a
> > > controller.
> > > But, I can't get it to work.
> > > I read the manual on accessing more than one model from a
> controller
> > > (http://manual.cakephp.org/chapter/controllers).
> > > It seems that it only works if the tables are in one same
> database.
> >
> > > Here is an example :
> > > This is the content of language.php :
> > > class Language extends AppModel
> > > {
> > > var $name = 'Language';
> > > var $useDbConfig = 'global';
> > > var $useTable = 'languages;
> >
> > > }
> >
> > > This is the content of site.php:
> > > class Site extends AppModel
> > > {
> > > var $name = 'Site';
> > > var $useDbConfig = 'en';
> > > var $useTable = 'sites';
> >
> > > }
> >
> > > Then in sites_Controlller.php I tried to access both of the table.
> > > class SitesController extends AppController {
> > > var $name = 'Sites';
> > > var $uses = array('Site' , 'Language');
> >
> > > function index()
> > > {
> > > set('test_site',
> $this->Site->findByContent('desciption);
> > > set('test_language',
> $this->Language->findByLanguage('en');
> > > }
> >
> > > }
> >
> > > It works for $test_language, it displays the value.
> > > But it display nothing for $test_site. It's empty.
> > > When I set the DEBUG to 2, I see that it run the query on
> > > global.sites, instead of en.sites table.
> > > Did I forget anything here ?
> > > Or maybe it doesn't allow a control accessing tables in different
> > > database?
> >
> > > Any help will be very appreciated.
> > > TIA
> >
> > > ?>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---