ID: 35800
Updated by: [EMAIL PROTECTED]
Reported By: vinny at xs4all dot nl
-Status: Open
+Status: Bogus
Bug Type: PostgreSQL related
Operating System: winxp sp2
PHP Version: 5.1.1
New Comment:
RTFM: pg_query_params() expects the last parameter to be an array(),
also, there's pg_escape_bytea() function which you can use too.
Previous Comments:
------------------------------------------------------------------------
[2005-12-25 12:53:00] vinny at xs4all dot nl
Description:
------------
pg_query_params() stops processing binary 'bytea' field data at hex
'00'.
Reproduce code:
---------------
<?php
/**
create a PostgreSQL database (I used 8.1) with a table that has a
'bytea' field. Use pg_query_params to insert binary data from a JPG
image into the bytea field, something like:
*/
pg_query_params("INSERT INTO tabel (byteafield) values ($1)",
file_get_contents('file.jpg'));
?>
Expected result:
----------------
The image should be stored in the database completely.
Actual result:
--------------
Only the first four bytes of the JPG data make it into the database.
JPG data starts with: hex FF D8 FF E0 00 10 4A 46 49
Apparently pg_query_params stops processing the content at '00' which I
guess is because PHP thinks it is at 'EOF'.
If you insert the data with a normal pg_query call and using
pg_escape_bytea() on the JPG data then everything works just fine and
the image is stored properly.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35800&edit=1