Home > php教程 > php手册 > php连接oracle及简单操作

php连接oracle及简单操作

WBOY
Release: 2016-06-21 08:49:04
Original
896 people have browsed it

使你的php支持oracle,按照以下步骤即可:

1.安装php环境,找一下appserv或者xampp,一键安装,很方便

2.把php的ext目录下的php_oci8.dll拷到system32目录下

3.修改php.ini文件中的配置,去掉  ;extention = php_oci8.dll,去掉前面的分号

4.重启apache

 

两种方式和oracle数据库建立链接

1.$conn = oci_connect('username','password',"(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST=192.168.1.100)(PORT = 1521))(CONNECT_DATA =(SID=test)))");

2.$conn = oci_connect('username','password','192.168.1.100/test'); 

有的时候第一种方式不行,使用第二种,里面的几个参数分别是用户名、密码、oracle服务地址,其中test是服务名。

 

$sql = "select * from table_exmaple"

$ora_test = oci_parse($conn,$sql);  //编译sql语句

oci_execute($ora_test,OCI_DEFAULT);  //执行

while($r=oci_fetch_row($ora_test))  //取回结果

{

echo $ora_test[0];

echo "
";  

}



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template