PHP 致命错误:找不到类“PDO”

2022-08-30 09:23:37
PHP Fatal error:  Class 'PDO' not found in /home/bd/public_html/app/webroot/Cake/Model/Datasource/Database/Mysql.php on line 177

PHP 信息:

PDO

PDO support => enabled
PDO drivers => sqlite, sqlite2, mysql

pdo_mysql

PDO Driver for MySQL => enabled
Client API version => 5.5.24

Directive => Local Value => Master Value
pdo_mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock

pdo_sqlite

PDO Driver for SQLite 3.x => enabled
SQLite Library => 3.7.7.1

PHP INI:

extension=pdo.so
extension=pdo_sqlite.so
extension=sqlite.so
extension=pdo_mysql.so

法典:

/**
 * Check whether the MySQL extension is installed/loaded
 *
 * @return boolean
 */
        public function enabled() {
                return in_array('mysql', PDO::getAvailableDrivers());
        }

关于为什么我收到此错误的想法?

PHP 5.3.15 CloudLinux/CentOS 6 CPanel


答案 1

尝试

 yum install php-pdo
 yum install php-pdo_mysql

 service httpd restart

答案 2

尝试在命名空间之后或类之前或文件顶部添加。use PDO;PHP


推荐