Thursday, August 8, 2013

CakePHP: Accessing database.php values

$fields = get_class_vars('DATABASE_CONFIG')

print_r($fields['default']);
or you can use; 
 
App::Import('ConnectionManager');
$ds = ConnectionManager::getDataSource('default');
$dsc = $ds->config;

print_r($dsc);
Will output like this:
Array
(
    [persistent] => 
    [host] => localhost
    [login] => root
    [password] => 
    [database] => db_name
    [port] => 3306
    [driver] => mysql
    [prefix] => 
) 

No comments:

Post a Comment