Re: Storing images in PG? - Mailing list pgsql-general

From Karel Zak
Subject Re: Storing images in PG?
Date
Msg-id 20010816100200.A29792@zf.jcu.cz
Whole thread Raw
In response to Storing images in PG?  ("Dr. Evil" <drevil@sidereal.kz>)
Responses Re: Re: Storing images in PG?  (Tod McQuillin <devin@spamcop.net>)
List pgsql-general
On Thu, Aug 16, 2001 at 06:02:00AM -0000, Dr. Evil wrote:
>
>
> I am creating a DB which is going to have to store a lot of small
> images.  Nothing will be over 10k.  This is with PG7.2.  I have a few
> questions: Should I use blob or bytea (neither seem to be well
> documented), and how do I access that binary information?  For
> instance, if I have this table in PG:
>
> CREATE TABLE imagetable (
>        ....
>        image BYTEA,
>        ....
> );
>
> and then I do this in PHP:
>
> $result = pg_exec($db, "SELECT image FROM imagetable WHERE ...");
> $ary = pg_fetch_array($result, 0);
> $imagedata = $ary["image"];
>
> Will all of the above work?

 Yes, but good is encode binary data (image) to same ascii safe encoding
like base64, else you will have problem in INSERT/UPDATE queries.

            Karel

--
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

pgsql-general by date:

Previous
From: "Dr. Evil"
Date:
Subject: Storing images in PG?
Next
From: Mark kirkwood
Date:
Subject: Re :MySQL Benchmark page - Problem with vacuum() in PostgreSQL