首先必须保证php的编译已经加入oracle库并成功!
连接代码:
//连接
$dbconn = oci_connect('username','password',"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.2)(PORT=1521))(CONNECT_DATA=(SID=sid)))");
if ($dbconn) {
echo '连接成功';
}else {
echo '连接失败';
}
//查询
$oci_rs = oci_parse($dbconn,‘SELECT * FROM user_tables'); //预处理SQL
oci_execute($oci_rs); //执行SQL
while ($row = oci_fetch_array($oci_rs,OCI_ASSOC)) {
print_r($row);
}//处理结果