嘿,伙计们,我很难解决这个问题:如何使用 application.ini 中的资源启动 zend_Db_Select 对象?
$db = Zend_Registry::get('db'); $select = $db->select();
但它不起作用,我想我必须先将 db 添加到注册表中还是什么?不知道该怎么做。有任何想法吗?我在 application.ini 中有我的数据库详细信息
嘿,伙计们,我很难解决这个问题:如何使用 application.ini 中的资源启动 zend_Db_Select 对象?
$db = Zend_Registry::get('db'); $select = $db->select();
但它不起作用,我想我必须先将 db 添加到注册表中还是什么?不知道该怎么做。有任何想法吗?我在 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.