I need to retrieve values from CakePHP's config file database.php from one of my controllers.
I'm maintaining an ex-employee's code, so I'm not positive how much of this adheres to default structures. I'm hoping this is fairly straightforward, but I can't seem to Google the right info.
File: app/config/database.php
class DATABASE_CONFIG
{
    var $db1 =
        array('driver' => 'mysqli',
              'connect' => 'mysql_connect',
              'host' => 'localhost',
              'login' => 'username',
              'password' => 'password',
              'database' => 'schema',
              'prefix' => '');
}
File: app/controllers/my_controller.php
// here is where I need to retrieve
// the database login and password values
What syntax can I use here? Is it even possible to retrieve these values, or are they only accessible to the guts of the CakePHP framework?
$fields = get_class_vars('DATABASE_CONFIG')
echo $fields['db1']['login'];
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With