Saturday, February 11, 2012

Multiple database connections in CakePHP 2.1 can't works

Hello all,

I've download fresh CakePHP 2.1 and try to make multiple database
connections. Here are my configuration :

Config/default.php :

<?php
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'cake_one',
);

public $navigator = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'port' => 3306,
'login' => 'root',
'password' => '',
'database' => 'cake_two',
);
}


Model/Navigator.php

<?php
App::uses('AppModel', 'Model');
/**
* Navigator Model
*
*/
class Navigator extends AppModel {
/**
* Primary key field
*
* @var string
*/
public $useDbConfig = 'navigator';
public $useTable = false;

}


Controller/NavigatorsController.php :
<?php
App::uses('AppController', 'Controller');

/**
* Navigators Controller
*
* @property Navigator $Navigator
* @property SecurityComponent $Security
*/
class NavigatorsController extends AppController {

/**
* Helpers
*
* @var array
*/
public $helpers = array('Html', 'Form');
public $uses = array('Driver');

/**
* index method
*
* @return void
*/
public function index() {
$this->Drive->recursive = 0;
$this->set('Drive', $this->paginate());
}


And when accessing /navigators/index , I got :

Error: Table drivers for model Driver was not found in datasource
default.
Notice: If you want to customize this error message, create app/View/
Errors/missing_table.ctp

"was not found in datasource default." it mean cakephp still look at
default not navigator.

Any wrong here ?

Thanks


--
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate