Apache zend框架中的数据库配置
当zend framework中的某些内容与数据库连接相关时,我遇到了错误。服务器是运行apache的unix服务器 这是我的application.ini配置 resources.db.adapter=pdo_mysql resources.db.params.host=localhost resources.db.params.username=a5633138_酒店 resources.db.params.password=passowrd resources.db.params.dbname=a5633138_酒店 resources.db.isDefaultTableAdapter=trueApache zend框架中的数据库配置,apache,zend-framework,Apache,Zend Framework,当zend framework中的某些内容与数据库连接相关时,我遇到了错误。服务器是运行apache的unix服务器 这是我的application.ini配置 resources.db.adapter=pdo_mysql resources.db.params.host=localhost resources.db.params.username=a5633138_酒店 resources.db.params.password=passowrd resources.db.params.dbna
如果是live server,是否需要配置其他内容?例如,如果我在主机部分中编写localhost,是否可以。用以下内容替换ErrorController.php
<?php
class ErrorController extends Zend_Controller_Action
{
public function errorAction()
{
$this->_helper->layout()->disableLayout();
$errors = $this->_getParam('error_handler');
if (!$errors || !$errors instanceof ArrayObject) {
$this->view->message = 'You have reached the error page';
return;
}
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setHttpResponseCode(404);
$priority = Zend_Log::NOTICE;
$this->view->message = 'Page not found';
break;
default:
// application error
$this->getResponse()->setHttpResponseCode(500);
$priority = Zend_Log::CRIT;
$this->view->message = 'Application error';
break;
}
// Log exception, if logger available
$log = $this->getLog();
if ($log) {
$log->log($this->view->message, $priority, $errors->exception);
$log->log('Request Parameters', $priority, $errors->request->getParams());
}
// conditionally display exceptions
if ($this->getInvokeArg('displayExceptions') == true) {
$this->view->exception = $errors->exception;
}
$this->view->request = $errors->request;
}
public function getLog()
{
$bootstrap = $this->getInvokeArg('bootstrap');
if (!$bootstrap->hasResource('Log')) {
return false;
}
$log = $bootstrap->getResource('Log');
return $log;
}
}
注意:未定义变量:第33行登录/home/a5633138/public_html/application/controllers/ErrorController.php,第34行调用/home/a5633138/public_html/application/controllers/ErrorController.php中非对象上的成员函数log,但这只发生在需要连接到数据库的页面中。它将在引发异常的任何情况下都会发生。注释第34行或在这里发布代码。实际上,这在本地服务器上运行良好。我知道每当抛出异常时,就会出现这种情况。是的,我知道了,消息:SQLSTATE[28000][1045]拒绝用户“a5633138_hotel@'localhost”使用密码进行访问:是的,但问题是我使用的是相同的登录名,在phpmyadmin中密码是正确的,这很有趣@AkramYakubov我发现密码拼写错误“passowrd”可能是其故意的。其他原因可能是您的phpmyadmin在同一台DB服务器上本地运行,并且您正在与DB服务器建立远程连接。需要给同一个用户额外的权限。最后,我解决了这个问题,问题是主机。我提到我放了localhost,但实际上工作主机是mysql8.000webhost.com