ID: 39341 User updated by: jasen at treshna dot com Reported By: jasen at treshna dot com -Status: Feedback +Status: Open Bug Type: PostgreSQL related Operating System: debian linux PHP Version: 4.4.4 New Comment:
new example code: I reallise that pg_insert is experimental, but it _seems_ to be working perfectly. Reproduce code: --------------- <? $data="/'/'\"\001\002\003\004"; # sample data to test with # you may need to use a different database... $db=pg_connect('dbname=template1'); if (!$db) die( "couldn't connect to database") ; if (!pg_query("CREATE TEMPORARY TABLE mytab ( a BYTEA ) ; ")) die( "couldn't create table\n") ; if (!pg_insert($db, 'mytab',array(a=> $data ))) die( "couldn't insert data\n") ; $res=pg_query("SELECT a FROM mytab"); if (!$res) die( "query failed\n") ; $row=pg_fetch_assoc($res); if ($row['a'] == $data ) echo "Retrieved data matched inserted -GOOD!\n"; elseif (pg_unescape_bytea($row['a']) == $data) echo "Retrieved data matched escaped version of inserted data - oops!\n"; else echo "Retrieved and insterted data differ :(\n"; ?> Expected result: ---------------- Retrieved data matched inserted -GOOD Actual result: ------------------- Retrieved data matched escaped version of inserted data - oops! Previous Comments: ------------------------------------------------------------------------ [2006-11-08 14:38:47] [EMAIL PROTECTED] Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2006-11-02 05:20:30] jasen at treshna dot com Description: ------------ I have a postgresql database table with a bytea field I insert into a record into this table using pg_insert but when I extract the data using pg_fetch_assoc the binary data is still escaped and needs to be unescaped using pg_unescape_bytea Reproduce code: --------------- $db=pg_connect('dbname=foo'); $res=pg_query("select * from images limit 1"); $row=pg_fetch_assoc($res); header("content-type: $row[type]"); echo /*pg_unescape_bytea(*/$row['data']); /* unescape is needed - is this a bug in php? */ Expected result: ---------------- I would expect my binary image to display in the browser Actual result: -------------- the browser complains about corruption in the image closer examination reveals that the data is still escaped. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39341&edit=1