Re: ByteA for binary data? - Mailing list pgsql-general

From Robert Myers
Subject Re: ByteA for binary data?
Date
Msg-id Pine.BSF.4.21.0202250006091.32359-100000@ns1.whiterose.net
Whole thread Raw
In response to Re: ByteA for binary data?  ("Thomas T. Thai" <tom@minnesota.com>)
List pgsql-general
You were right.  I had blown off your intial email becuase I thought that
the pg_escape_bytea was the same as your function, so I disregarded the
rest. :)

Sorry about that.

I've got it all working now, thanks again for putting up with my
inadquecies. :)

-Bob
ccrider@whiterose.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:
>
> > 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?
>
> please re-read my original message included below. it stated that you need
> to use PHP function stripcslashes() on the data from the db before you can
> use it. all of this was said in my ORIGINAL email to you. please also note
> that 'c' in that function. that's NOT the usual stripslashes();
>
> > 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;
> > > > > }
> > >
> > >
> > >
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
> >
>
> ---
> Thomas T. Thai | Minnesota.com | tom@minnesota.com | 612.220.6220
> Visit http://www.minnesota.com/
>
>
>


pgsql-general by date:

Previous
From: "Thomas T. Thai"
Date:
Subject: Re: ByteA for binary data?
Next
From: Joe Conway
Date:
Subject: Re: ByteA for binary data?