1--TEST-- 2PostgreSQL pg_escape_bytea() functions (before connection) 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php include("skipif.inc"); ?> 7--FILE-- 8<?php 9// optional functions 10 11include('config.inc'); 12 13$image = file_get_contents(__DIR__ . '/php.gif'); 14$esc_image = pg_escape_bytea($image); 15 16$db = pg_connect($conn_str); 17@pg_query($db, "SET bytea_output = 'escape'"); 18 19pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, E\''.$esc_image.'\');'); 20$result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876'); 21$rows = pg_fetch_all($result); 22$unesc_image = pg_unescape_bytea($rows[0]['bin']); 23 24if ($unesc_image !== $image) { 25 echo "NG"; 26} 27else { 28 echo "OK"; 29} 30?> 31--EXPECTF-- 32Deprecated: pg_escape_bytea(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d 33OK 34