简体   繁体   中英

How to initiate Zend_Db_Select object?

Hey guys, I'm having truble figuring this out: how do I initiate a zend_Db_Select object with the resources from my application.ini?

$db = Zend_Registry::get('db'); $select = $db->select();

But it's not working, I guess I have to add db to the registry first or something? Not sure how to do that though. Any ideas? I have my database details in application.ini

You can only get objects from the registry which have been set before. So

$db = Zend_Registry::get('db'); $select = $db->select();

will return null, not an db adapter. You can initialize the adapter via the bootstrap. Read:

http://framework.zend.com/manual/en/zend.application.theory-of-operation.html hxxp://www.zendframework.com/manual/en/zend.application.available-resources.html

For the initialization of the db adapter (which is done by the bootstrap resource plugin for you) read:

hxxp://framework.zend.com/manual/en/zend.db.adapter.html

I wouldn't recommend using the registry at all, it is better to get the resources from the bootstrap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM