Re: ByteA for binary data?

From: Robert Myers <ccrider(at)whiterose(dot)net>
To: "Thomas T(dot) Thai" <tom(at)minnesota(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ByteA for binary data?
Date: 2002-02-25 04:36:20
Message-ID: Pine.BSF.4.21.0202242335330.29322-100000@ns1.whiterose.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes, if I use your function it works. NP.

The problem I have now, is what do I have to do special to get the data
back out in proper format? Or does it come out in useable form?

-Bob
ccrider(at)whiterose(dot)net
Systems Administrator for whiterose.net
http://www.whiterose.net

On Sun, 24 Feb 2002, Thomas T. Thai wrote:

> On Sun, 24 Feb 2002, Robert Myers wrote:
>
> > I did this with the CVS version of PHP, v 4.2.0 dev.
> >
> > I downloaded it for the function pg_escape_bytea, still no go, I can't get
> > the data into the field.
>
> did you try as i said below? i've tested it on php 4.0.6 - 4.1.0. i've not
> used pg_escape_bytea so i can't comment on it.
>
> > > > I'm having a problem with the bytea datatype. I'm trying to store image
> > > > data inside the field in a table, and php seems to only be sending a small
> > > > portion of the image into the database.
> [...]
> > > to use bytea with php, encode the image data with escByteA() below before
> > > storing it in your db. then when you retrieve the data, use php's
> > > stripcslashes(). i've tested this on various image data and they all work
> > > just fine.
> > >
> > > function escByteA($binData) {
> > > /**
> > > * \134 = 92 = backslash, \000 = 00 = NULL, \047 = 39 = Single Quote
> > > *
> > > * str_replace() replaces the searches array in order.
> > > * Therefore, we must
> > > * process the 'backslash' character first. If we process it last, it'll
> > > * replace all the escaped backslashes from the other searches that came
> > > * before. tomATminnesota.com
> > > */
> > > $search = array(chr(92), chr(0), chr(39));
> > > $replace = array('\\\134', '\\\000', '\\\047');
> > > $binData = str_replace($search, $replace, $binData);
> > > return $binData;
> > > }
>
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas T. Thai 2002-02-25 04:58:39 Re: ByteA for binary data?
Previous Message Robert Myers 2002-02-25 04:35:24 Re: ByteA for binary data?