I am looking to register a reference to the main Database Adapter in the Registry during Bootstrapping so it can be used elsewhere in my site (specifically the Authorisation action).
I have implemented an ugly fix where i create a Database Table object and call the getAdapter() method on it and pass through that. However, this is a bad way of doing it and I would like it to be available via the registry.
Does anyone know how to do this? Any help or pointers in the right direction are appreciated!
Cheers
Stuart
Ps. Im using Zend Framework 1.8.
Best Answer
If you're using Zend Framework 1.8+, and created your project with the command line tool, then it's as simple as registering your database settings in your
application.ini
config file.If your database settings are preceded by
resources.db
you won't even need to do anything in yourBootstrap.php
file because it will do it for you. Also, by setting theisDefaultTableAdapter
setting totrue
, you can get an instance of your database adapter anywhere in your application.