我需要使用PHP PDO连接到MariaDB数据库才能正常工作。但是当我通过处理器运行php文件时,它会抛出一个错误:
Fatal error: Uncaught PDOException: could not find driver in C:\Users
\...\Documents\Visual Studio 2017\Projects\...\...
\dashboard.php:16
Stack trace:
#0 C:\Users\...\Documents\Visual Studio 2017\Projects\...
\...\dashboard.php(16): PDO->__construct('mysql:host=;dbn...',
NULL, NULL, Array)
#1 {main}
thrown in C:\Users\...\Documents\Visual Studio 2017\Projects
\...\...\dashboard.php on line 16
我在php.ini中启用了PDO驱动程序
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dll
extension=php_pdo_obdc.dll
答案 0 :(得分:0)
发现问题,当我在php文件中运行phpinfo()时发现:
Loaded Configuration File => (none)
原来执行该文件的进程忽略了php.ini文件。