Linux

PHP致命錯誤:找不到類’PDO'

  • December 31, 2012
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:

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

關於我為什麼會收到此錯誤的想法?

PHP 5.3.15 CloudLinux/CentOS 6 CPanel

這可能是由於命名空間問題,在這種情況下您需要轉義 PDO,例如:

$indexes = $this->dbh->cubrid_schema(\PDO::CUBRID_SCH_CONSTRAINT, $table->getName());

有關更多詳細資訊,請參閱此答案https://stackoverflow.com/a/6901395/556678

引用自:https://serverfault.com/questions/414429