PHP 8.4.2 Released!

Pdo\Pgsql::setNoticeCallback

(PHP 8 >= 8.4.0)

Pdo\Pgsql::setNoticeCallbackSet a callback to handle notice and warning messages generated by the backend

Descrição

public Pdo\Pgsql::setNoticeCallback(?callable $callback): void

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

Parâmetros

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

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

handler(string $message): void
message
A message generated by the backend.

Valor Retornado

Nenhum valor é retornado.

Exemplos

Exemplo #1 Pdo\Pgsql::setNoticeCallback() 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->setNoticeCallback(function ($message) {
echo
$message;
});

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

O exemplo acima produzirá algo semelhante a:

NOTICE:  truncate cascades to table "child"
adicione uma nota

Notas Enviadas por Usuários (em inglês)

Não há notas de usuários para esta página.
To Top