Annotation of embedaddon/php/ext/pgsql/tests/18pg_escape_bytea_hex.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: PostgreSQL pg_escape_bytea() functions (hex format)
! 3: --SKIPIF--
! 4: <?php
! 5: include("skipif.inc");
! 6: skip_bytea_not_hex();
! 7: ?>
! 8: --FILE--
! 9: <?php
! 10: // optional functions
! 11:
! 12: include('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:
! 20: pg_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:
! 25: if ($unesc_image !== $image) {
! 26: echo "NG";
! 27: }
! 28: else {
! 29: echo "OK";
! 30: }
! 31: ?>
! 32: --EXPECT--
! 33: OK
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>