2.
$conn = oci_connect('username','password','192.168.1.100/test');
set adocon=Server.Createobject("adodb.connection") adocon.open"Driver={microsoft odbc for oracle};server=oraclesever.world;uid=admin;pwd=pass;"
set adocon=Server.Createobject("adodb.connection") adocon.open"Provider=OraOLEDB.Oracle;data source=dbname;user id=admin;password=pass;"
$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 "<BR>"; }
oci_connect ( username, password , dbname )
<?php $conn = oci_connect('hr', 'hr', 'orcl'); // 建立连接 if (!$conn) { $e = oci_error(); print htmlentities($e['message']); exit; } $query = 'SELECT * FROM DEPARTMENTS'; // 查询语句 $stid = oci_parse($conn, $query); // 配置SQL语句,准备执行 if (!$stid) { $e = oci_error($conn); print htmlentities($e['message']); exit; } $r = oci_execute($stid, OCI_DEFAULT); // 执行SQL。OCI_DEFAULT表示不要自动commit if(!$r) { $e = oci_error($stid); echo htmlentities($e['message']); exit; } // 打印执行结果 print '<table border="1">'; while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) { print '<tr>'; foreach($row as $item) { print '<td>'.($item?htmlentities($item):' ').'</td>'; } print '</tr>'; } print '</table>'; oci_close($conn); ?>
希望本文所述对大家的php程序设计有所帮助。