在Windows(xampp)上安装PHP PDO [英] PHP PDO installation on windows (xampp)

查看:139
本文介绍了在Windows(xampp)上安装PHP PDO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个Web应用程序,该应用程序可以在PHP上连接到尽可能多的不同数据库. PDO( http://www.php.net/manual/en/book.pdo.php)似乎是正确的接口,但是我在安装所需的所有不同PDO数据库驱动程序所需的所有扩展时遇到了麻烦.

I am trying to develop a web app that can connect to as many different databases as possible on PHP. PDO (http://www.php.net/manual/en/book.pdo.php) seems to be the right interface for it but I am having trouble installing all the extentions needed for all the different PDO database drivers that I need.

请注意,我在Windows 7计算机上使用xampp. PHP版本5.3.8. PDO驱动程序启用了mysql,odbc,sqlite,sqlite2,sqlsrv.

Please note that I use xampp on a windows 7 machine. PHP Version 5.3.8. PDO drivers enabled mysql, odbc, sqlite, sqlite2, sqlsrv.

我已成功连接以下设备:

I have successfully connected with the following:

  • MySQL 使用 PDO_MYSQL [MySQL(PDO)](扩展名似乎默认安装在xampp上)
  • Microsoft SQL Server 使用 PDO_SQLSRV [MS SQL Server(PDO)](遵循
  • MySQL using PDO_MYSQL [MySQL (PDO) ] (extension seemed to be installed on xampp by default)
  • Microsoft SQL Server using PDO_SQLSRV [MS SQL Server (PDO)] (followed the instractions on http://craigballinger.com/blog/2011/08/usin-php-5-3-with-mssql-pdo-on-windows/)

我没有运气来安装或连接:

I had no luck installing or connecting with:

  • (已解决,请参阅以下更新) Sybase (我尝试使用并安装 PDO_DBLIB [MS SQL Server(PDO)],但没有成功)
  • (已解决的更新问题) Oracle (在重新启动Apache之后,我尝试使用xampp所安装的dll来启用php.ini中的extension = php_pdo_oci.dll,但服务器无法启动.尝试使用 PDO_OCI [Oracle(PDO)])
  • (SOLVED SEE BELOW UPDATES) Sybase (I tried to use and install PDO_DBLIB [MS SQL Server (PDO)]but with no luck)
  • (SOLVED SEE BELOW UPDATES)Oracle (I tried to enable the extension=php_pdo_oci.dll in php.ini with the dll that was installed with xampp after restarting Apache the server failed to start. Was trying to use PDO_OCI [Oracle (PDO)])

我知道我可以使用数据库特定的驱动程序来解决这2个问题,但是我真的很想使用PDO满足我的所有需求.

I know I can work around those 2 with using the database specific drivers but I would really love to use PDO for everything that I need.

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

Does anyone know how to install and enable PDO_DBLIB and PDO_OCI drivers or a windows machine, or any other way of connecting with Sybase and Oracle databases using PDO?

更新

通过 PDO_OCI 成功连接到 oracle .您需要执行以下操作:

Just succesfully connected with oracle with PDO_OCI. What you need to do is the following:

在Windows计算机上下载并安装适当的Oracle Instant Client,以用于 示例InstantClient_12_1并将其路径添加到SYSTEM中的PATH 环境变量.注意Oracle仅向下支持2个版本,因此请选择 您的客户端版本正确.这样做,然后重新启动Apache.请注意,连接字符串与此处有很大不同,这是我使用的示例:

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);  


更新

只需连接 Sybase PDO_ODBC .您需要的是以下内容:

Just connected with Sybase as well with PDO_ODBC. What you need is the following:

必须具有SDK随附的Sybase ASE 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,$myUser,$myPass);  

推荐答案

所以我终于设法连接到四个数据库,这就是我的管理方式:

So i finally managed to connect to four database here's how I managed:

MySQL 似乎已安装在xampp上,不需要做很多工作.这是我用于连接的代码:

MySQL using PDO_MYSQL extension seemed to be installed on xampp by default didn't have to do much work. Here is the code I used for the connection:

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


使用 PDO_SQLSRV

Microsoft SQL Server 遵循


Microsoft SQL Server using PDO_SQLSRV followed the instructions on http://craigballinger.com/blog/2011/08/usin-php-5-3-with-mssql-pdo-on-windows/. Here is the code I used:

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


Oracle PDO_OCI .在Windows计算机上下载并安装适当的Oracle Instant Client,例如Instantclient_12_1,然后将其路径添加到SYSTEM环境变量中的PATH.注意Oracle仅向下支持2个版本,因此请正确选择客户端版本.这样做,然后重新启动Apache.这是我使用的代码:


Oracle with PDO_OCI. 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. Here is the code 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);  


具有 PDO_ODBC

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


Sybase with PDO_ODBC Must have Sybase ASE ODBC Driver which comes with the SDK. Here is the code I used:

$connStr = "odbc:Driver={Adaptive Server Enterprise};server=".$myServer.";port=".$myPort.";db=".$myDB;
$conn = new PDO($connStr,$myUser,$myPass);  

这篇关于在Windows(xampp)上安装PHP PDO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆