0

嘿,伙计们,我很难解决这个问题:如何使用 application.ini 中的资源启动 zend_Db_Select 对象?

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

但它不起作用,我想我必须先将 db 添加到注册表中还是什么?不知道该怎么做。有任何想法吗?我在 application.ini 中有我的数据库详细信息

4

1 回答 1

0

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.

于 2011-01-21T00:51:53.673 回答