pg_last_notice

pg_last_notice

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

pg_last_notice Returns the last notice message from PostgreSQL server

Description

string pg_last_notice ( resource $connection )

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.

Return Values

A string containing the last notice on the given connection, 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

© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/function.pg-last-notice.php

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部