Issue
I have two(default and test) db connections in my database.php:
public function __construct() {
$this->default = array(
'datasource' => 'Database/Mysql',
'driver' => 'mysql',
'persistent' => false,
'encoding' => 'utf8',
'prefix' => 'shaufel_',
'host' => 'localhost',
'database' => 'db',
'login' => 'root', /*** replace this ***/
'password' => 'root', /*** replace this ***/
);
//test db
$this->test = $this->default;
$this->test['database'] = $this->test['database'].'_test';
}
How can I get the current DB connection NAME in my Model ? That means for example : if(current_db is testDB) do something
. I use Cakephp 2.9.7.
Solution
I found it by myself: $this->getDataSource()->config['database']
Answered By - handkock
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.