PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #6658

bytea data insertion doesont work for me

Details

Submitted2006-02-01 16:56 UTC
Frommuaddib at kopernet dot org
StatusBogus
PackageDB
PHP Version4.3.10
OSdebian sarge
Roadmaps(Not assigned)

Comments

[2006-02-01 16:56 UTC] muaddib at kopernet dot org

Description:
------------
I dont know if this is really a bug or just my lack of knowledge but

Inserting() data into PostgreSQL 7.4.7 results in error:

ERROR: invalid input syntax for type bytea

Test script:
---------------
$data = file_get_contents($myfilename);
$image->binarydata = pg_escape_bytea($data);
$image->insert();

// when i change to this..
//$data = file_get_contents($myfilename);
//$image->binarydata = pg_escape_bytea($data);
//$image->query("insert into table (column) values('$image->binarydata'));
//..all goes as expected.

//also i can insert an empty string.

Actual result:
--------------
2006-02-01 14:24:11 [22633] LOG: statement: INSERT INTO public.binarydata (binarydata ) VALUES ('\\\\377\\\\330\\\\377\\\\340\\\\000\\\\020JFIF\\\\000\\\\001

(...)

\\\\210\\\\200""\\\\000\\\\210\\\\210\\\\002" \\\\010\\\\210\\\\200\\\\377\\\\331' )
2006-02-01 14:24:11 [22633] ERROR: invalid input syntax for type bytea

[2006-02-01 23:38 UTC] muaddib at kopernet dot org

my workarround:

cast $data as a blob

require_once 'DB/DataObject/Cast.php';
$data=file_get_contents($myfilename);
$image->binarydata=DB_DataObject_Cast::blob($data));
$image->insert();

thx;)