1--TEST-- 2PostgreSQL notice function 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php 7 8include("inc/skipif.inc"); 9 10_skip_lc_messages($conn); 11 12?> 13--FILE-- 14<?php 15include 'inc/config.inc'; 16include 'inc/lcmess.inc'; 17 18ini_set('pgsql.log_notice', TRUE); 19ini_set('pgsql.ignore_notice', FALSE); 20 21$db = pg_connect($conn_str); 22 23_set_lc_messages($db); 24 25$res = pg_query($db, 'SET client_min_messages TO NOTICE;'); 26var_dump($res); 27 28// Get empty notice 29var_dump(pg_last_notice($db)); 30var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL)); 31 32pg_query($db, "BEGIN;"); 33pg_query($db, "BEGIN;"); 34pg_query($db, "BEGIN;"); 35pg_query($db, "BEGIN;"); 36 37// Get notices 38var_dump(pg_last_notice($db)); 39var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL)); 40 41// Clear and get notices 42var_dump(pg_last_notice($db, PGSQL_NOTICE_CLEAR)); 43var_dump(pg_last_notice($db, PGSQL_NOTICE_LAST)); 44var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL)); 45 46// Invalid option 47try { 48 var_dump(pg_last_notice($db, 99)); 49} catch (\ValueError $e) { 50 echo $e->getMessage() . \PHP_EOL; 51} 52?> 53--EXPECTF-- 54object(PgSql\Result)#%d (0) { 55} 56string(0) "" 57array(0) { 58} 59 60Notice: pg_query(): %s already a transaction in progress in %s on line %d 61 62Notice: pg_query(): %s already a transaction in progress in %s on line %d 63 64Notice: pg_query(): %s already a transaction in progress in %s on line %d 65string(52) "WARNING: there is already a transaction in progress" 66array(3) { 67 [0]=> 68 string(52) "WARNING: there is already a transaction in progress" 69 [1]=> 70 string(52) "WARNING: there is already a transaction in progress" 71 [2]=> 72 string(52) "WARNING: there is already a transaction in progress" 73} 74bool(true) 75string(0) "" 76array(0) { 77} 78pg_last_notice(): Argument #2 ($mode) must be one of PGSQL_NOTICE_LAST, PGSQL_NOTICE_ALL, or PGSQL_NOTICE_CLEAR 79