简体   繁体   English

PHP PDO - 看不到可用的驱动程序

[英]PHP PDO - can't see available drivers

I am new to php pdo and I have to connect to MySQL driver but when I try to see which driver is available with我是 php pdo 的新手,我必须连接到 MySQL 驱动程序,但是当我尝试查看哪个驱动程序可用时

print_r(PDO::getAvailableDrivers())

returns empty array.What I have to do to see that MySQL driver is available?返回空数组。我必须做什么才能看到 MySQL 驱动程序可用?

I encountered a similar issue before, PDO return error message Could not find driver , but when I check, PDO is working fine, but has empty available drivers.我之前遇到过类似的问题,PDO 返回错误消息Could not find driver ,但是当我检查时,PDO 工作正常,但有空的可用驱动程序。

Later, I found out that the solution to my issue is, change the c:\php path in the system environment to c:\xampp\php .后来我发现解决我的问题的方法是,将系统环境中的c:\php路径改为c:\xampp\php You might save your PHP or XAMPP in a different location, but you get the idea.您可以将 PHP 或 XAMPP 保存在不同的位置,但您明白了。

The thing is, before I use phpMyAdmin , I already installed a PHP on my computer, and set the system path to this PHP.问题是,在我使用phpMyAdmin之前,我已经在我的电脑上安装了一个 PHP,并将系统路径设置为这个 PHP。 But later I install XAMPP because I wanna use MySQL , but my system environment still runs PHP code through the old PHP path.但是后来我安装了 XAMPP 因为我想使用MySQL ,但是我的系统环境仍然通过旧的 PHP 代码运行 PHP 代码。 After changing the path, the problem solved.更改路径后,问题解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM