How can use two database in same project in zend framework
I have a project in Zend Framework. I want call two database in same project, meaning I want to get values from the second database in the same project.
Please post step by step instruction with code and filename on开发者_运维问答 how to connect to the two databases.
There is a related question here connecting to two different databases with Zend Framework but I could not understand the code. Can someone please post mor information about this topic.
The answer to the other question is mostly self-descriptive * connecting to two different databases with Zend Framework
In the first codeblock, two database connections are created with names 'db' and 'db2', and they are added to the Registry
In the second block, the connections are picked from the Registry
public function init() { $this->db = Zend_Registry::get('db'); $this->db2 = Zend_Registry::get('db2'); }
You can then run your queries on the fetched objects.
To use this code
Read more on Zend_Registry here http://framework.zend.com/manual/en/zend.registry.using.html
精彩评论