Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could read application.ini on controller using zend framework

I have these lines in my application.ini

how can I read user in my contrroler

resources.doctrine.dbal.connections.default.parameters.driver   = "pdo_mysql"
resources.doctrine.dbal.connections.default.parameters.dbname   = "zc"
resources.doctrine.dbal.connections.default.parameters.host = "localhost"
resources.doctrine.dbal.connections.default.parameters.port = 3306
resources.doctrine.dbal.connections.default.parameters.user = "root"
resources.doctrine.dbal.connections.default.parameters.password = "123456"

I use of this code but it retuens null

$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
 $user = $bootstrap->getOption('user');
var_dump($user);

edit: how may I read all of connections options ?

like image 588
ulduz114 Avatar asked Feb 13 '26 06:02

ulduz114


1 Answers

I think you should use

$this->getInvokeArgs('bootstrap');

For more info see this chapter in manual.

What about using

$conf = $bootstrap->getOption('resources');
$dbConf = $conf['doctrine']['dbal']['connections']['default']['parameters'];
like image 173
Tomáš Fejfar Avatar answered Feb 14 '26 20:02

Tomáš Fejfar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!