Resolving "PHP Fatal error: Class 'PDO' not found" Exception
The "Class 'PDO' not found" error typically occurs when the PHP Data Objects (PDO) extension is not installed or enabled. To resolve this issue, follow these steps:
1. Check if PDO is installed:
Run the following command to check if PDO is installed:
php -m | grep PDO
If PDO is installed, it will be listed as an extension.
2. Enable PDO in PHP.ini:
If PDO is installed but not enabled, open the PHP.ini file and look for the following lines:
extension=pdo.so extension=pdo_mysql.so
Ensure that these lines are uncommented (i.e., do not have a semicolon at the beginning of the line).
3. Install and enable PDO MySQL:
The specific error "Class 'PDO' not found in /home/bd/public_html/app/webroot/Cake/Model/Datasource/Database/Mysql.php" indicates that the MySQL PDO driver is not enabled. Run the following commands to install and enable it:
sudo yum install php-pdo sudo yum install php-pdo_mysql service httpd restart
Once these steps are completed, restart your Apache web server (e.g., Apache, Nginx, etc.). The "Class 'PDO' not found" error should now be resolved.
The above is the detailed content of How to Fix the \'PHP Fatal error: Class \'PDO\' not found\' Exception?. For more information, please follow other related articles on the PHP Chinese website!