PHP 7.4.25 Released!


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

pg_last_notice Returns the last notice message from PostgreSQL server


pg_last_notice ( resource $connection , int $option = PGSQL_NOTICE_LAST ) : mixed

pg_last_notice() returns the last notice message from the PostgreSQL server on the specified connection. The PostgreSQL server sends notice messages in several cases, for instance when creating a SERIAL column in a table.

With pg_last_notice(), you can avoid issuing useless queries by checking whether or not the notice is related to your transaction.

Notice message tracking can be set to optional by setting 1 for pgsql.ignore_notice in php.ini.

Notice message logging can be set to optional by setting 0 for pgsql.log_notice in php.ini. Unless pgsql.ignore_notice is set to 0, notice message cannot be logged.



PostgreSQL database connection resource.


One of PGSQL_NOTICE_LAST (to return last notice), PGSQL_NOTICE_ALL (to return all notices), or PGSQL_NOTICE_CLEAR (to clear notices).

Valorile întoarse

A string containing the last notice on the given connection with PGSQL_NOTICE_LAST, an array with PGSQL_NOTICE_ALL, a bool with PGSQL_NOTICE_CLEAR, or false on error.


Example #1 pg_last_notice() example

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

Exemplul de mai sus va afișa:

CREATE TABLE will create implicit sequence "test_id_seq" for "serial" column ""

Istoricul schimbărilor

Versiune Descriere
7.1.0 The option parameter was added.

A se vedea și

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top