使用 Zend 数据库时出现一些 Zend 消息错误 [英] I got Some Zend Message Error when Working Zend Database

查看:34
本文介绍了使用 Zend 数据库时出现一些 Zend 消息错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误消息:

<前>致命错误:未捕获的异常Zend_Exception",消息为文件Zend\Db\Adapter\Mysql.php"不存在或在 C:\wamp\www\VPZ\Lib\ 中的文件中找不到类Zend_Db_Adapter_Mysql"Zend\Loader.php:88堆栈跟踪:#0 C:\wamp\www\VPZ\Lib\Zend\Db.php(247): Zend_Loader::loadClass('Zend_Db_Adapter...')#1 C:\wamp\www\VPZ\VPZ_Grid\core\vpz_datagrid.class.php(16): Zend_Db::factory('mysql')#2 C:\wamp\www\vpz_test.php(9): VPZ_DataGrid->ConnectDb(Object(VPZ_Connector))#3 {main} 在第 88 行的 C:\wamp\www\VPZ\Lib\Zend\Loader.php 中抛出

我不知道这是怎么回事,在Zend\Db\Adapter\Mysql.php"中找到目录没有但有 Mysqli.php

解决方案

我认为您正在尝试使用 MySQL 适配器创建 Zend_Db 对象.Zend Framework 默认没有 MySQL 适配器.您应该使用 MySQLi 适配器或 Pdo_Mysql.签出您的代码,您在其中创建 Zend_Db 对象.传入Pdo_Mysql"作为您的适配器名称,而不是Mysql":

 $_db = Zend_Db::factory('Mysql', $configArray );//使用 mysql 适配器,默认情况下不可用.$_db1 = Zend_Db::factory('Mysqli', $configArray);//使用 mysqli 适配器,但需要安装 php_mysqli 扩展.$_db1 = Zend_Db::factory('Pdo_Mysql', $configArray);//使用 PDO mysql 适配器,这要好得多,但需要安装 PDO,大多数情况下已安装.

您可以为 Zend_Db 编写自己的适配器.编写一个类并扩展 Zend_Db_Adapter_Abstract.但是实现 Mysql 适配器存在一些问题,因为 PHP_MySQL 扩展(将为 PHP 提供 mysql_* 函数)不支持许多功能(如客户端存储过程,...).所以你不能实现其他 Zend_Db_Adapters 的所有方法.我以前做过这个.我想使用我的应用程序,它使用 Zend Framework,并将它托管在未安装 PDO 和 Mysqli 的服务器上.我为 Zend_Db 实现了一个 Mysql 适配器,但是因为我知道哪些方法没有实现,所以我避免调用它们.最好的办法是,如果您可以安装 PDO,并使用 Pdo_* 适配器.

I get the following error message:

Fatal error: Uncaught exception 'Zend_Exception' with message 'File "Zend\Db\Adapter\Mysql.php" does not exist or class "Zend_Db_Adapter_Mysql" was not found in the file' in C:\wamp\www\VPZ\Lib\Zend\Loader.php:88 
Stack trace: 
#0 C:\wamp\www\VPZ\Lib\Zend\Db.php(247): Zend_Loader::loadClass('Zend_Db_Adapter...')
#1 C:\wamp\www\VPZ\VPZ_Grid\core\vpz_datagrid.class.php(16): Zend_Db::factory('mysql')  
#2 C:\wamp\www\vpz_test.php(9): VPZ_DataGrid->ConnectDb(Object(VPZ_Connector))
#3 {main} thrown in C:\wamp\www\VPZ\Lib\Zend\Loader.php on line 88

I dont know what about this and find directory in "Zend\Db\Adapter\Mysql.php" not have but have Mysqli.php

解决方案

you are trying to create a Zend_Db object with MySQL adapter, I think. there is no MySQL adapter by default for Zend Framework. you should use MySQLi adapter, or Pdo_Mysql. checkout your code, where you are creating your Zend_Db object. pass in 'Pdo_Mysql' as your adapter name, instead of 'Mysql':

 $_db = Zend_Db::factory('Mysql', $configArray );
 // uses mysql adapter, which is not available by default.

 $_db1 = Zend_Db::factory('Mysqli', $configArray );
 // uses mysqli adapter, but needs php_mysqli extension to be installed.

 $_db1 = Zend_Db::factory('Pdo_Mysql', $configArray );
 // uses PDO mysql adapter which is much better, but needs PDO to be installed, which most of times is installed.

you can write your own adapter for Zend_Db. write a class and extend the Zend_Db_Adapter_Abstract. but there are some problems to implement Mysql adapter, because PHP_MySQL extension (that will provide PHP with mysql_* functions) does not support many features (like client stored procedures, ...). so you can not implement all of methods that other Zend_Db_Adapters have. I've done this before. I wanted to use my application, that used Zend Framework, and I hosted it on a server that PDO and Mysqli were not installed. I implemented a Mysql adapter for Zend_Db, but because I knew which methods are not implemented, I avoided calling those. the best thing is if you could have PDO installed, and use Pdo_* adapters.

这篇关于使用 Zend 数据库时出现一些 Zend 消息错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆