pg_last_notice

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

pg_last_notice 返回 PostgreSQL 服務(wù)器最新一條公告信息

說明

pg_last_notice(resource $connection): string

pg_last_notice() 返回由 connection 指定的 PostgreSQL 服務(wù)器最新的一條公告信息。PostgreSQL 服務(wù)器在某些情況下會發(fā)送公告信息,例如在表里創(chuàng)建 SERIAL 列。

有了 pg_last_notice(),只要檢查公告是否和該事務(wù)有關(guān),就可以避免提交無用的查詢。

可以通過在 php.ini 中把 pgsql.ignore_notice 置為 1 來使公告信息追蹤成為可選項。

可以通過在 php.ini 中把 pgsql.log_notice 置為 0 來使公告信息日志成為可選項。 除非 pgsql.ignore_notice 為 0,否則公告信息不能被日志記錄。

參數(shù)

connection

PostgreSQL database connection resource.

返回值

A string containing the last notice on the given connection, or false on error.

更新日志

版本 說明
4.3.0 本函數(shù)在 PHP 4.3.0 中完全實現(xiàn)。低于 PHP 4.3.0 的版本中都忽略了數(shù)據(jù)庫連接參數(shù)。
4.3.0 The pgsql.ignore_notice and pgsql.log_notice php.ini directives were added.
4.0.6 PHP 4.0.6 本身在公告信息處理上有問題。即使不使用 pg_last_notice() 函數(shù),也不推薦在 PHP 4.0.6 中使用 PostgreSQL 模塊。

范例

示例 #1 pg_last_notice() example

<?php
  $pgsql_conn 
pg_connect("dbname=mark host=localhost");
  
  
$res pg_query("CREATE TABLE test (id SERIAL)");
  
  
$notice pg_last_notice($pgsql_conn);
  
  echo 
$notice;
?>

以上例程會輸出:

CREATE TABLE will create implicit sequence "test_id_seq" for "serial" column "test.id"

參見