ID:               39341
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jasen at treshna dot com
-Status:           Assigned
+Status:           Feedback
 Bug Type:         PostgreSQL related
 Operating System: debian linux
 PHP Version:      4.4.4
 Assigned To:      yohgaki
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi




Previous Comments:
------------------------------------------------------------------------

[2006-11-09 05:56:11] jasen at treshna dot com

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!

------------------------------------------------------------------------

[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

Reply via email to