1--TEST-- 2PostgreSQL pg_escape_bytea() functions (hex format) 3--SKIPIF-- 4<?php 5include("skipif.inc"); 6skip_bytea_not_hex(); 7?> 8--FILE-- 9<?php 10// optional functions 11 12include('config.inc'); 13 14$db = pg_connect($conn_str); 15@pg_query($db, "SET bytea_output = 'hex'"); 16 17$image = file_get_contents(dirname(__FILE__) . '/php.gif'); 18$esc_image = pg_escape_bytea($image); 19 20pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');'); 21$result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876'); 22$rows = pg_fetch_all($result); 23$unesc_image = pg_unescape_bytea($rows[0]['bin']); 24 25if ($unesc_image !== $image) { 26 echo "NG"; 27} 28else { 29 echo "OK"; 30} 31?> 32--EXPECT-- 33OK 34