当前位置:Gxlcms > 数据库问题 > php 连接oracle

php 连接oracle

时间:2021-07-01 10:21:17 帮助过:4人阅读

$conn = oci_connect(‘111‘,‘111‘,"(DESCRIPTION=(ADDRESS=(PROTOCOL =TCP)(HOST=10.101.0.36)(PORT = 1521))(CONNECT_DATA =(SID=orcl)))");
  
  if (!$conn) {
   $e = oci_error();
   var_dump($e[‘message‘]);
   //trigger_error(htmlentities($e[‘message‘], ENT_QUOTES), E_USER_ERROR);
  }

  $sql1 = "select * from nls_database_parameters"; // 查询字符集
  $sql2 = "select userenv(‘language‘) from dual"; // 查询字符集
  $sql3 = "select * from file ";

  $sql4 = "INSERT INTO file VALUES (‘123010101‘,‘1‘)";
 
  echo "start\n";

  $stmt = oci_parse($conn, "$sql4");
  oci_execute($stmt, OCI_DEFAULT);

  $committed = oci_commit($conn);
  if (!$committed) {
         $error = oci_error($conn);
         echo ‘Commit failed. Oracle reports: ‘ . $error[‘message‘];
     };


  while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
   foreach ($row as $item) {
    echo ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "\n";
   };
  };
  echo "end\n";

  var_dump( oci_close($conn) );

php 连接oracle

标签:

人气教程排行