我开始学习Zend Framework,我设置了我的第一个项目并创建了我的数据库并在IndexController中编写了动作indexAction但是当我试图看到
时
网址http://localhost/zf-tutorial/public/我收到以下错误:
未捕获的异常'Zend_Db_Adapter_Exception',消息'配置数组必须有一个用于登录凭据的'用户名'的密钥'在/opt/lampp/htdocs/zf-tutorial/library/Zend/Db/Adapter/Abstract.php:292堆栈跟踪:#0 /opt/lampp/htdocs/zf-tutorial/library/Zend/Db/Adapter/Abstract.php(183):Zend_Db_Adapter_Abstract-> _checkRequiredOptions(Array)#1 / opt / lampp / htdocs / zf- tutorial / library / Zend / Db.php(265):Zend_Db_Adapter_Abstract-> __ construct(Array)#2 /opt/lampp/htdocs/zf-tutorial/library/Zend/Application/Resource/Db.php(142):Zend_Db :: factory('PDO_MYSQL',Array)#3 /opt/lampp/htdocs/zf-tutorial/library/Zend/Application/Resource/Db.php(154):Zend_Application_Resource_Db-> getDbAdapter()#4 / opt / lampp / htdocs / zf-tutorial / library / Zend / Application / Bootstrap / BootstrapAbstract.php(680):Zend_Application_Resource_Db-> init()#5 / opt / lampp / htdocs / zf-tutorial / library / Zend / Application / Bootstrap /BootstrapAbstract.php(623):Zend_Appli在/ opt / lampp / htdocs / zf-中的cation_Bootstrap_BootstrapAbstract-> _executeResource('db')#6 / opt / lampp / htdocs / zf-tut- 第292行的tutorial / library / Zend / Db / Adapter / Abstract.php
我尝试了几种解决方案(在application.ini中修改我的配置),但它没有用 这是我的application.ini文件的片段
[制作] phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH“/../library”
bootstrap.path = APPLICATION_PATH“/Bootstrap.php”
bootstrap.class =“Bootstrap”
appnamespace =“申请”
resources.frontController.controllerDirectory = APPLICATION_PATH“/ controllers”
resources.frontController.params.displayExceptions = 0
phpSettings.date.timezone =“欧洲/法国”
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.user = mona
resources.db.params.password = mona
resources.db.params.dbname = zf-tutorial
resources.layout.layoutPath = APPLICATION_PATH“/ layouts / scripts /”
resources.view.doctype =“XHTML1_STRICT”
任何想法。
感谢。
答案 0 :(得分:3)
这一行
resources.db.params.user = mona
应该阅读
resources.db.params.username = mona
答案 1 :(得分:0)
将resources.db.params.user = mona
更改为resources.db.params.username = mona
在application.ini
文件中。
Zend找不到数据库连接的属性username