PHP PDO找不到驱动程序

时间:2017-06-22 14:54:45

标签: php mysql pdo php-7.1

我需要使用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

1 个答案:

答案 0 :(得分:0)

发现问题,当我在php文件中运行phpinfo()时发现:

Loaded Configuration File => (none)

原来执行该文件的进程忽略了php.ini文件。