pg_last_notice
(PHP 4 >= 4.0.6, PHP 5, PHP 7)
pg_last_notice — Returns the last notice message from PostgreSQL server
Description
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.
Parameters
-
connection
-
PostgreSQL database connection resource.
-
option
-
One of
PGSQL_NOTICE_LAST
(to return last notice),PGSQL_NOTICE_ALL
(to return all notices), orPGSQL_NOTICE_CLEAR
(to clear notices).
Return Values
A string containing the last notice on the
given connection
with
PGSQL_NOTICE_LAST
,
an array with PGSQL_NOTICE_ALL
,
a boolean with PGSQL_NOTICE_CLEAR
,
or FALSE
on error.
Examples
Example #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;
?>
The above example will output:
CREATE TABLE will create implicit sequence "test_id_seq" for "serial" column "test.id"
See Also
- pg_query() - Execute a query
- pg_last_error() - Get the last error message string of a connection
English translation
You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.
Thank you in advance.
Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-pg-last-notice.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.