简体   繁体   English

如何包含Zend_DB类?

[英]How to include Zend_DB class?

I want to use the class Zend_Db (and other Zend classes later). 我想使用Zend_Db类(以及以后的其他Zend类)。 However, after 5 hours I am still not able to access this class. 但是,在5个小时后,我仍然无法访问该课程。 Could someone please point me towards a solution? 有人可以指出我的解决方案吗? It would already be helpful to know which of the hundreds files in the Zend framework contains this class? 了解Zend框架中的数百个文件中的哪个包含此类已经对您有所帮助了? Thanks a million in advance! 预先感谢一百万!

More details on my problem: I am receiving the following error message 有关我的问题的更多详细信息:我收到以下错误消息

Fatal error: Class 'Zend_Db' not found 致命错误:找不到类'Zend_Db'

upon doing the following: 在执行以下操作时:

1) Downloaded Zend 2.2.5 and moved it to my server at /home/www/Zend/library 1)下载Zend 2.2.5并将其移至我的服务器,位于/home/www/Zend/library

2) Added following line to php.ini: include_path=".:/home/www/Zend/library" 2)向php.ini添加了以下代码行: include_path=".:/home/www/Zend/library"

3) Ran following index.php: 3)运行以下index.php:

    require_once 'Zend/Loader/AutoloaderFactory.php';
    require_once 'Zend/Loader/StandardAutoloader.php';
    require_once 'Zend/Loader/SplAutoloader.php';
    $options = array(Zend_Db::AUTO_QUOTE_IDENTIFIERS => true);

    $db = new Zend_Db_Adapter_Pdo_Mysql(array(
        'host'     => MYSQL_HOST,
        'username' => MYSQL_BENUTZER,
        'password' => MYSQL_KENNWORT,
        'dbname'   => MYSQL_DATENBANK,
        'options' => $options
        ));`

Background: It's my first time using Zend. 背景:这是我第一次使用Zend。 I am working on an Apache Server with PHP 5.3.21. 我正在使用PHP 5.3.21开发Apache服务器。 I am using Zend 2.2.5 我正在使用Zend 2.2.5

The code you've included was written for ZF1, but you have downloaded ZF2. 您包含的代码是为ZF1编写的,但是您已经下载了ZF2。 The two are not compatible. 两者不兼容。 You need to either change your code to work with ZF2, or download the latest version of ZF1. 您需要更改代码以使用ZF2,或下载最新版本的ZF1。

If you really want to use Zend_DB, you can use the composer autoloader and setup a classmap. 如果您确实要使用Zend_DB,则可以使用composer自动加载器并设置一个类映射。 Define where the classmap should look and with ./composer.phar install you automagically generate a class-map in which composer will do the rest. 定义类映射的外观,并使用./composer.phar安装,自动生成一个类映射,其余内容由作曲家完成。

With ZF2 I presume you use composer, if not, use it. 我假设使用ZF2,如果您不使用作曲家,请使用它。 This website also contains the basics on how to use it: 该网站还包含有关如何使用它的基础知识:
- http://getcomposer.org/doc/04-schema.md#classmap -http://getcomposer.org/doc/04-schema.md#classmap

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM