开发者

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_Regis开发者_StackOverflow中文版try::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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜