oci_error

(PHP 5, PHP 7, PECL OCI8 >= 1.1.0)

oci_error锟斤拷锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷

说锟斤拷

oci_error ([ resource $source ] ) : array

锟斤拷锟节达拷锟斤拷锟斤拷锟斤拷螅锟斤拷锟斤拷锟斤拷锟斤拷屎系锟斤拷锟皆达拷锟斤拷锟斤拷锟斤拷锟斤拷 oci_connect()锟斤拷oci_new_connect() 锟斤拷 oci_pconnect() 锟斤拷锟斤拷锟接达拷锟襟,诧拷要锟斤拷锟捷诧拷锟斤拷锟斤拷锟斤拷锟矫伙拷蟹锟斤拷执锟斤拷锟�oci_error() 锟斤拷锟斤拷 FALSE锟斤拷oci_error() 锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷锟介返锟截达拷锟斤拷锟节达拷锟斤拷锟斤拷锟叫o拷code 锟斤拷 oracle 锟斤拷锟斤拷锟斤拷锟斤拷 message 锟斤拷 oracle 锟侥达拷锟斤拷锟街凤拷锟斤拷锟斤拷

Note: 锟斤拷 PHP 4.3 锟斤拷

offset 锟斤拷 sqltext 也锟斤拷锟斤拷锟节凤拷锟截碉拷锟斤拷锟斤拷锟叫o拷锟斤拷锟斤拷指锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷位锟斤拷锟皆硷拷锟斤拷纱锟斤拷锟斤拷原始锟斤拷 SQL 锟侥憋拷锟斤拷

Example #1 锟斤拷锟接达拷锟斤拷锟斤拷锟绞� Oracle 锟斤拷锟斤拷锟斤拷息

$conn = @oci_connect("scott", "tiger", "mydb");
if (!$conn) {
  $e = oci_error();   // For oci_connect errors pass no handle
  echo htmlentities($e['message']);
}

Example #2 锟斤法锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞� Oracle 锟斤拷锟斤拷锟斤拷息

$stmt = @oci_parse($conn, "select ' from dual");  // note mismatched quote
if (!$stmt) {
  $e = oci_error($conn);  // For oci_parse errors pass the connection handle
  echo htmlentities($e['message']);
}

Example #3 执锟叫达拷锟斤拷锟斤拷锟绞� Oracle 锟斤拷锟斤拷锟斤拷息锟酵筹拷锟斤拷锟斤拷锟斤拷

$r = oci_execute($stmt);
if (!$r) {
  $e = oci_error($stmt); // For oci_execute errors pass the statementhandle
  echo htmlentities($e['message']);
  echo "<pre>";
  echo htmlentities($e['sqltext']);
  printf("\n%".($e['offset']+1)."s", "^");
  echo "</pre>";
}

Note:

锟斤拷 PHP 5.0.0 之前锟侥版本锟斤拷锟斤拷使锟斤拷 ocierror() 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷煤锟斤拷锟斤拷锟斤拷锟饺伙拷锟斤拷茫锟轿拷锟斤拷录锟斤拷锟斤拷锟轿� oci_error() 锟侥憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟窖憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟狡硷拷使锟矫★拷