In order to dynamically select DB during runtime in cakePHP is try to do it in Controller or in Model.
To do it in model:
class User extends AppModel {
var $name = 'User';
var $useDbConfig = 'general_syst';
function __construct($id = false, $table = null, $ds = null) {
$this->useDbConfig = 'db1';
parent::__construct($id, $table, $ds);
}
// your code here
// ....
}
When in controller
class Users extends AppController {
function action1(){
$this->User->useDbConfig = 'db1';
$users = $this->User->find('all');
// your code here
// ....
}
}
Hope this one helps.
Parthiv Patel
Bhaishri Info Solution
Sr. PHP Developer
Limdi Chowk, AT PO. Nar, Di. Anand
Nar, Gujarat
388150
India
pparthiv2412@gmail.com
7383343029
DOB: 12/24/1986
No comments:
Post a Comment