diff options
author | Yasuo Ohgaki <yohgaki@php.net> | 2002-04-05 06:05:28 +0000 |
---|---|---|
committer | Yasuo Ohgaki <yohgaki@php.net> | 2002-04-05 06:05:28 +0000 |
commit | 22007a29de4382095f479b18f191325e593bcbf6 (patch) | |
tree | d1628082356ead69aa579e9e4c7bc471cff55eb7 | |
parent | eb7ed9105ab595ca828938c6d0af69fdf4c05023 (diff) | |
download | php-git-22007a29de4382095f479b18f191325e593bcbf6.tar.gz |
Add real pg_escape_bytea() test.
-rw-r--r-- | ext/pgsql/tests/08escape.phpt | 1 | ||||
-rw-r--r-- | ext/pgsql/tests/escape.inc | 32 | ||||
-rw-r--r-- | ext/pgsql/tests/php.gif | bin | 0 -> 3872 bytes |
3 files changed, 31 insertions, 2 deletions
diff --git a/ext/pgsql/tests/08escape.phpt b/ext/pgsql/tests/08escape.phpt index ce4e22a7bf..a26e0162ed 100644 --- a/ext/pgsql/tests/08escape.phpt +++ b/ext/pgsql/tests/08escape.phpt @@ -9,3 +9,4 @@ include("escape.inc"); --EXPECT-- pg_escape_string() is Ok pg_escape_bytea() is Ok +pg_escape_bytea() actually works with databse diff --git a/ext/pgsql/tests/escape.inc b/ext/pgsql/tests/escape.inc index c02ac423f8..f7517952f0 100644 --- a/ext/pgsql/tests/escape.inc +++ b/ext/pgsql/tests/escape.inc @@ -1,6 +1,11 @@ <?php -$before = "ABC\\ABC"; -$expect = "ABC\\\\ABC"; + +include 'config.inc'; +define('FILE_NAME', './php.gif'); + +// pg_escape_string() test +$before = "ABC\\ABC\'"; +$expect = "ABC\\\\ABC\\'"; $after = pg_escape_string($before); if ($expect === $after) { echo "pg_escape_string() is Ok\n"; @@ -12,6 +17,7 @@ else { var_dump($expect); } +// pg_escape_bytea() test $before = "ABC\\ABC"; $expect = "ABC\\\\\\\\ABC"; $after = pg_escape_bytea($before); @@ -25,4 +31,26 @@ else { var_dump($expect); } +// Test using database +$fp = fopen(FILE_NAME,'r'); +$data = fread($fp, filesize(FILE_NAME)); + +$db = pg_connect($conn_str); +$escaped_data = pg_escape_bytea($data); +//$out = fopen('php.gif_escaped','w'); +//fwrite($out, $escaped_data); +//exit; +pg_query("DELETE FROM ".$table_name." WHERE num = -2;"); +$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-2, '".$escaped_data."');"; +pg_query($db, $sql); +$sql = "SELECT * FROM ".$table_name." WHERE num = -2"; +$result = pg_query($db, $sql); +$row = pg_fetch_row($result, 0); +if ($data === $row['bin']) { + echo "pg_escape_bytea actually works\n"; +} +else { + echo "pg_escape_bytea is broken\n"; +} + ?> diff --git a/ext/pgsql/tests/php.gif b/ext/pgsql/tests/php.gif Binary files differnew file mode 100644 index 0000000000..7beda43fd4 --- /dev/null +++ b/ext/pgsql/tests/php.gif |