$conn = oci_connect('sharedb','kingstar',"(DEscriptION=(ADDRESS=(PROTOCOL =TCP)(HOST=172.16.0.21)(PORT = 1521))(CONNECT_DATA =(SID=ORCL)))"); if (!$conn) { $e = oci_error(); print htmlentities($e['message']); exit; }else{ echo 'success'; } $query = 'SELECT * FROM DEPT'; // 查询语句 $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; } // 打印执行结果 while($row = oci_fetch_array($stid, OCI_RETURN_NULLS)) { $arr[]=$row; } oci_close($conn); print_r($arr);