aci_error

aci_error — 返回上一个错误

说明

aci_error(resource $source = ?): array

对于大多数错误,参数是最适合的资源句柄。对于 aci_connect()aci_new_connect() 的连接错误,不要传递参数。如果没有发现错误,aci_error() 返回 false。 aci_error() 以一个关联数组返回错误。在此数组中,code 是数据库 错误代码而 message 是 oracle 的错误字符串。

注意: 自 PHP 4.3 起
offset 和 sqltext 也包括在返回的数组中,用来指出错误发生的位置以及造成错误的原始的 SQL 文本。

示例 #1 连接错误后显示 数据库 错误信息

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

示例 #2 语法解析错误后显示 数据库 错误信息

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

示例 #3 执行错误后显示 数据库 错误信息和出错的语句

$r = aci_execute($stmt);
if (!$r) {
  $e = aci_error($stmt); // For aci_execute errors pass the statementhandle
  echo htmlentities($e['message']);
  echo "<pre>";
  echo htmlentities($e['sqltext']);
  printf("\n%".($e['offset']+1)."s", "^");
  echo "</pre>";
}
注意:在 PHP 5.0.0 之前的版本必须使用 acierror() 替代本函数。该函数名仍然可用,为向下兼容作为 aci_error() 的别名。不过其已被废弃,不推荐使用。