使用 Zend_Db_Table_Abstract::createRow() 时遇到问题
我已经构建了一个扩展 Zend_Db_Table_Abstract 的模型,但我不明白为什么我不能使用 createRow();这是我的代码:
class Model_User extends Zend_Db_Table_Abstract
{
public function createUser()
{
$row = $this->createRow();
$row->name = 'test';
$row->save();
}
}
在我使用的控制器中:
$userModel = new Model_User();
$userModel->createUser();
运行时显示错误
发生错误
应用程序错误
是我在 application.ini 中的设置
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "pass"
resources.db.params.dbname = "app_db"
resources.db.isDefaultTableAdapter = true
我确信我的用户/密码/数据库名是正确的。
如果您为我指出正确的方向,我将不胜感激。
I have built a model that extends Zend_Db_Table_Abstract and I can't figure out why I can't use createRow(); here is my code:
class Model_User extends Zend_Db_Table_Abstract
{
public function createUser()
{
$row = $this->createRow();
$row->name = 'test';
$row->save();
}
}
and in a controller I use:
$userModel = new Model_User();
$userModel->createUser();
which when run displays an error
An error occurred
Application error
here is my setup in application.ini
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = "pass"
resources.db.params.dbname = "app_db"
resources.db.isDefaultTableAdapter = true
I am sure that my user/pass/dbname is correct.
I would appreciate it if you point me in the right direction.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Vika 的提示是正确的,尽管您应该将以下所有内容添加到 app.ini 文件的开发部分
然后您(和我们)将获得有关问题所在的更多信息
Vika's hint is correct though you should add all the following to the development section of your app.ini file
Then you (and we) will get much more information about what's wrong
确保您的
ErrorController
类具有显示错误的代码。如果您删除显示Exception
的代码,那么您将永远不知道出了什么问题。Make sure that your
ErrorController
class has code to show you the errors. If you remove the code which displays theException
then you'll never know what is wrong.