php - 未找到 ZF2 类 PDO,但在 php 配置中启用了 PDO

标签 php mysql pdo zend-framework2

我的 zf2 应用程序一直运行良好,但突然开始出现此错误

fatal error :第 21 行/home/doaminName/public_html/xxxxx.com/config/autoload/global.php 中未找到“PDO”类

我的 PHP 版本是 native 版本 (5.4),这是来自 phpinfo 的配置命令。 PDO 通过这一行 --enable-pdo=shared 启用。

'./configure' '--enable-bcmath' '--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-mbstring' '--enable-pdo=shared' '--enable-soap' '--enable-sockets' '--enable-zip' '--prefix=/usr/local' '--with-bz2' '--with-curl=/opt/curlssl/' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libdir=lib64' '--with-libexpat-dir=/usr' '--with-libxml-dir=/opt/xml2' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-pcre-regex=/opt/pcre' '--with-pdo-mysql=shared' '--with-pdo-sqlite=shared' '--with-pic' '--with-png-dir=/usr' '--with-tidy=/opt/tidy/' '--with-xmlrpc' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr'

知道问题出在哪里吗?

最佳答案

嗯,你可以尝试在global.php第21行将其设为\PDO

所有后续对 PDOException 的调用也必须进行转换。

如果它不起作用,那么你的 php 是在没有 PDO 的情况下构建的。

关于php - 未找到 ZF2 类 PDO,但在 php 配置中启用了 PDO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32525119/

相关文章:

php - 链接 MS Access 和数据库服务器而不安装任何额外的驱动程序

php - 尝试更新表中的图像但未执行更新

php - fatal error : Call to undefined function bindParam()

sql - 从 Laravel 4 中的不同 PostgreSQL 模式中选择表

php - PHP 网站和 AdSense 的广告轮播

PHP 表单不发送到同一服务器上的电子邮件地址

php - 从文本中过滤坏词

c# - 如何在同一行中找到重复的名称/值?可以算吗?

MySQL 复杂内连接

php - 了解 pdo mysql 事务