简体   繁体   English

PHP尝试通过PDO连接到Oracle 11g-未知错误

[英]Php trying to connect to Oracle 11g via PDO - unknown error

I'm trying to connect to an Oracle 11g Express Edition Database in php via PDO. 我正在尝试通过PDO连接到php中的Oracle 11g Express Edition数据库。 I have xampp installed, I also have a (supposedly) working pdo_oci extension, which also shows up in phpinfo(). 我安装了xampp,也有一个(据说)工作的pdo_oci扩展,它也显示在phpinfo()中。 My database works and I can connect to it via an sql console and/or sql developer. 我的数据库有效,我可以通过sql控制台和/或sql开发人员连接到它。 I have enabled the extension php_pdo_oci.dll 我启用了扩展名php_pdo_oci.dll

My code is: 我的代码是:

$db_username = "system";
$db_password = "mypass";
$db = "oci:dbname=xe";
$conn = new PDO($db,$db_username,$db_password);

I get the following error: 我收到以下错误:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[]: pdo_oci_handle_factory: <> (ext\\pdo_oci\\oci_driver.c:579)' in ... 致命错误:消息中出现'SQLSTATE []:pdo_oci_handle_factory:<>(ext \\ pdo_oci \\ oci_driver.c:579)的未捕获异常'PDOException'...

So this really doesnt tell anything. 所以这真的什么也没说。

If I try to connect via oci_connect and enable the extension php_oci8_11g.dll (and disable the pdo extension) then with this code: 如果我尝试通过oci_connect连接并启用扩展名php_oci8_11g.dll(并禁用pdo扩展名),则使用以下代码:

$conn = oci_connect('system', 'mypass', 'localhost/XE');

I get this error: 我收到此错误:

Warning: oci_connect() [function.oci-connect]: OCIEnvNlsCreate() failed. 警告:oci_connect()[function.oci-connect]:OCIEnvNlsCreate()失败。 There is something wrong with your system - please check that PATH includes the directory with Oracle Instant Client libraries in... 您的系统有问题-请检查PATH是否包含Oracle Instant Client库所在的目录...

So what is Oracle Instant Client? 那么什么是Oracle Instant Client? I only downloaded Oracle Express Edition, and added ORACLE_HOME and LD_LIBRARY_PATH as environmental vars and also added the path to PATH as well. 我只下载了Oracle Express Edition,并添加了ORACLE_HOME和LD_LIBRARY_PATH作为环境变量,还向PATH添加了路径。 Am I missing anything? 我有什么想念的吗?

Thank you in advance 先感谢您

Okay, I think I fixed it, so if anyone else needs it: 好吧,我想我已修复它,所以如果有人需要它:

I downloaded Oracle Instant Client. 我下载了Oracle Instant Client。 After this it was still complaining that I should put its place in the PATH, even if it was already there. 在此之后,它仍然在抱怨我应该将其放置在PATH中,即使它已经存在。

So I copied all the files in the Instant Client (probably you don't need all, but anyway) into the apache/bin dir and voila it worked. 因此,我将Instant Client中的所有文件(也许您不需要全部,但无论如何)都复制到apache / bin目录中,瞧,它起作用了。

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

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