简体   繁体   English

使用oci8模块和动态连接字符串通过PHP连接到Oracle

[英]Connect to Oracle with PHP using oci8 module and a dynamic connection string

I would like to connect to an Oracle DB from PHP using the oci8 module (oci_connect). 我想使用oci8模块(oci_connect)从PHP连接到Oracle DB。 I know how to do this, but the problem is I would like to do it dynamically based on a connection string of type 我知道如何执行此操作,但是问题是我想根据类型的连接字符串动态地执行此操作

"oci8://user_name:password@tns_name" “ oci8://用户名:密码@tns_name”

The oci_connect method needs the user_name, password and the tns_name (called connection string) separately. oci_connect方法分别需要user_name,password和tns_name(称为连接字符串)。 I would prefer not to parse my connection string to make the code more robust. 我宁愿不解析我的连接字符串以使代码更健壮。

Is there a way to do this ? 有没有办法做到这一点 ?

By the way, I'm using PHP 5.2.5 and Oracle 10g and I'm using the oci8 module to help me call a stored procedure. 顺便说一句,我正在使用PHP 5.2.5和Oracle 10g,并且正在使用oci8模块来帮助我调用存储过程。

解析字符串时,代码将更加健壮,因为您可以检测到无效的连接信息

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

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