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 ?
I think you should use
For more info see this chapter in manual.
What about using
This goes in your controller.
This should print "root".
How about something like:
Or during
Bootstrap
, create and save this$config
object in theBootstrap
or in theZend_Registry
for later retrieval in your controller.To get to the Doctrine container resource, just use :
From there you can drill down to the user name of the default connection (you can specify the connection if needed, just pass the name of the connection in the call to getConnection) :
In this case you should use Zend_Config_Ini class
second parameter is a section in INI file should be loaded ; third parameter is the key to allow modify loaded file.
You can put out value user this way:
you can set any variable using set method as following on index.php inside the public folder Let
$config = 'test'; Zend_Registry::set('config', $config);
once the variable has been set then you can get on any controllers/models by following method
Zend_Registry::get('config');
Hop it Helps!!