在Windows上安装PHP PDO(xampp)

前端之家收集整理的这篇文章主要介绍了在Windows上安装PHP PDO(xampp)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试开发一个可以在 PHP上连接到尽可能多的不同数据库的Web应用程序. PDO( http://www.php.net/manual/en/book.pdo.php)似乎是正确的界面,但我无法安装所需要的所有不同PDO数据库驱动程序所需的扩展.

请注意,我在Windows 7机器上使用xampp. PHP版本5.3.8. PDO驱动启用了MysqL,odbc,sqlite,sqlite2,sqlsrv.

我已经成功连接了以下内容

> MysqL使用PDO_MysqL [MysqL(PDO)](扩展名似乎默认安装在xampp上)
> Microsoft sql Server使用PDO_sqlSRV [MS sql Server(PDO)](后跟在http://craigballinger.com/blog/2011/08/usin-php-5-3-with-mssql-pdo-on-windows/)

我没有运气安装或连接:

>(解决了以下更新)Sybase(我试图使用和安装PDO_DBLIB [MS sql Server(PDO)]但没有运气)
(解决方案见下面的更新)Oracle(我尝试在PHP.ini中启用扩展名= PHP_pdo_oci.dll,其中安装了xampp的dll在重新启动Apache后,服务器启动失败.尝试使用PDO_OCI [Oracle(PDO) ])

我知道我可以使用数据库特定的驱动程序来解决这些问题,但我真的很乐意为我所需要的一切使用PDO.

有没有人知道如何安装和启用PDO_DBLIB和PDO_OCI驱动程序或Windows机器,或使用PDO与Sybase和Oracle数据库连接的任何其他方式?

UPDATE

只是使用PDO_OCI与oracle成功连接.你需要做的是:

Download and install the proper Oracle Instant Client on your windows machine for
example instantclient_12_1 and add its path to PATH in SYSTEM
Environmental Variables. Note Oracle supports only 2 versions down so select
your client version properly. Do that and then restart your Apache. Note that the connection string is very different from here is a sample of what I used:

$tns = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ".$myServer.")(PORT = 1521)))(CONNECT_DATA=(SID=".$myDB.")))"; 
$connStr = "oci:dbname=".$tns;      
$conn = new PDO($connStr,$myUser,$myPass);

UPDATE

刚刚与Sybase连接,也与PDO_ODBC连接.您需要的是以下内容

Must have Sybase ASE ODBC Driver which comes with the SDK. Find below the connection string used:

$connStr = "odbc:Driver={Adaptive Server Enterprise};server=".$myServer.";port=".$myPort.";db=".$myDB;
$conn = new PDO($connStr,$myPass);
所以我终于设法连接到四个数据库这里我是如何管理的:

MysqL使用PDO_MysqL扩展似乎是安装在xampp上默认没有做太多工作.以下是我用于连接的代码

$connStr = "MysqL:host=".$myServer.";dbname=".$myDB; 
$conn = new PDO($connStr,$myPass);

使用PDO_sqlSRV的Microsoft sql Server遵循http://craigballinger.com/blog/2011/08/usin-php-5-3-with-mssql-pdo-on-windows/上的说明.以下是我使用的代码

$connStr = "sqlsrv:Server=".$myServer.";Database=".$myDB; 
$conn = new PDO($connStr,$myPass);

Oracle与PDO_OCI.在Windows机器上下载并安装正确的Oracle Instant Client,例如instantclient_12_1,并将其路径添加到“系统环境变量”中.注意Oracle仅支持2个版本,因此请正确选择客户端版本.然后重新启动Apache.这是我使用的代码

$tns = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ".$myServer.")(PORT = 1521)))(CONNECT_DATA=(SID=".$myDB.")))"; 
$connStr = "oci:dbname=".$tns;      
$conn = new PDO($connStr,$myPass);

具有PDO_ODBC的Sybase必须具有SDK附带的Sybase ASE ODBC驱动程序.这是我使用的代码

$connStr = "odbc:Driver={Adaptive Server Enterprise};server=".$myServer.";port=".$myPort.";db=".$myDB;
$conn = new PDO($connStr,$myPass);
原文链接:https://www.f2er.com/windows/363781.html

猜你在找的Windows相关文章