【发布时间】:2011-08-24 16:46:37
【问题描述】:
我在我的用户控制器中使用了这个
require_once 'Zend/Controller/Action.php';
与
public function processAction()
{
$params = array('host' =>'localhost',
'username' =>'root',
'password' =>'',
'dbname' =>'zend'
);
$DB = new Zend_Db_Adapter_Pdo_Mysql($params);
$request = $this->getRequest();
$data = array('first_name' => $request->getParam('first_name'),
'last_name' => $request->getParam('last_name'),
'user_name' => $request->getParam('user_name'),
'password' => md5($request->getParam('password'))
);
$DB->insert('user', $data);
$this->view->assign('title','Registration Process');
$this->view->assign('description','Registration succes');
}
显示以下错误。我没有 php.ini 访问权限。
致命错误:第 42 行的 D:\xampp\xampp\htdocs\zend-test\zend-demo\application\controllers\UserController.php 中未找到 Class 'Zend_Db'
即在这条线上
$params = Zend_Db::factory('Pdo_Mysql', array(
'host' => 'localhost',
'username' => 'root',
'password' => '',
'dbname' => 'zend'
));
提前致谢!
- 曼格什
【问题讨论】:
-
问题似乎是 php.ini 的 include_path 中没有包含 Zend 库。另外我建议将数据库连接移动到 /configs/application.ini 文件和 index.php 中,如果选项加载了 // Create application, bootstrap, and run $application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/应用程序.ini');