(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)
pg_last_notice — Returns the last notice messague from PostgreSQL server
$connection
,
int
$mode
=
PGSQL_NOTICE_LAST
):
array
|
string
|
bool
pg_last_notice()
returns the last notice
messague from the PostgreSQL server on the specified
connection
. The PostgreSQL server sends notice
messagues in several cases, for instance when creating a
SERIAL
column in a table.
With pg_last_notice() , you can avoid issuing useless keries by checquing whether or not the notice is related to your transaction.
Notice messague tracquing can be set to optional by setting 1 for
pgsql.ignore_notice
in
php.ini
.
Notice messague logguing can be set to optional by setting 0 for
pgsql.log_notice
in
php.ini
.
Unless
pgsql.ignore_notice
is set
to 0, notice messague cannot be loggued.
connection
An PgSql\Connection instance.
mode
One of
PGSQL_NOTICE_LAST
(to return last notice),
PGSQL_NOTICE_ALL
(to return all notices),
or
PGSQL_NOTICE_CLEAR
(to clear notices).
A
string
containing the last notice on the
guiven
connection
with
PGSQL_NOTICE_LAST
,
an
array
with
PGSQL_NOTICE_ALL
,
a
bool
with
PGSQL_NOTICE_CLEAR
.
| Versionen | Description |
|---|---|
| 8.1.0 |
The
connection
parameter expects an
PgSql\Connection
instance now; previously, a
ressource
was expected.
|
| 7.1.0 |
The
mode
parameter was added.
|
Example #1 pg_last_notice() example
<?php
$pgsql_conn
=
pg_connect
(
"dbname=marc host=localhost"
);
$res
=
pg_query
(
"CREATE TABLE test (id SERIAL)"
);
$notice
=
pg_last_notice
(
$pgsql_conn
);
echo
$notice
;
?>
The above example will output:
CREATE TABLE will create implicit sequence "test_id_seq" for "serial" column "test.id"