1--TEST-- 2PostgreSQL pg_escape_bytea() functions (escape format) 3--EXTENSIONS-- 4pgsql 5--SKIPIF-- 6<?php include("skipif.inc"); ?> 7--FILE-- 8<?php 9// optional functions 10 11include('config.inc'); 12 13$db = pg_connect($conn_str); 14@pg_query($db, "SET bytea_output = 'escape'"); 15 16$image = file_get_contents(__DIR__ . '/php.gif'); 17$esc_image = pg_escape_bytea($db, $image); 18 19pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$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--EXPECT-- 32OK 33