[SOLVED] How to insert binary data into Postgresql?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
myleow
Forum Contributor
Posts: 194
Joined: Mon Jun 21, 2004 7:05 pm
Location: California

[SOLVED] How to insert binary data into Postgresql?

Post by myleow »

I have a HTTP_RAW_POST_DATA from a cell phone in WBXML encoding and i want to store it into the database. I created the column with BYTEA datatype since i know none of the raw data would exceed 1 GB, in fact it won't exceed 10k.

Anyway i am getting problem inserting using regular INSERT INTO because of the special characters ' \ that might be present in the RAW DATA.

I tried casting the data into bytea type using $data::bytea but that didn't help at all.

Anyone dealt with this situation before care to enlighten me please.

Regards
Mian

EDIT: pg_escape_bytea
Post Reply