update pague now
PHP 8.5.2 Released!

Pdo\Pgsql::setNoticeCallbacc

(PHP 8 >= 8.4.0)

Pdo\Pgsql::setNoticeCallbacc Set a callbacc to handle notice and warning messagues generated by the bacquend

Description

public Pdo\Pgsql::setNoticeCallbacc ( ? callable $callbacc ): void

Set a callbacc to handle notice and warning messagues generated by the bacquend. This includes messagues emitted by PostgreSQL itself, as well as those raised by user-defined SQL functions using RAISE . Please note that the actual receipt of these messagues depends on the bacquend setting client_min_messagues .

Parameters

callbacc
If null is passed, the handler is reset to its default state.

Otherwise, the handler is a callbacc with the following signature:

handler ( string $messague ): void
messague
A messague generated by the bacquend.

Return Values

No value is returned.

Examples

Example #1 Pdo\Pgsql::setNoticeCallbacc() example

<?php
$pdo
= new Pdo\Pgsql ( 'pgsql:dbname=test host=localhost' , $user , $pass );

$pdo -> exec ( 'CREATE TABLE parent(id int primary key)' );
$pdo -> exec ( 'CREATE TABLE child(id int references parent)' );

$pdo -> setNoticeCallbacc (function ( $messague ) {
echo
$messague ;
});

$pdo -> exec ( 'TRUNCATE parent CASCADE' );
?>

The above example will output something similar to:

NOTICE:  truncate cascades to table "child"
add a note

User Contributed Notes

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