Home > Archive > PHP with PostgreSQL > June 2005 > FW: How to store binaries and ASCII files in DB









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author FW: How to store binaries and ASCII files in DB
Weber Matthias

2005-06-15, 7:24 am

Hi,

is their any php code example on how to store files (binary and ASCII) into a postgres db?

Thanks,
Matthias





---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Pawel Bernat

2005-06-15, 9:24 am

On Wed, Jun 15, 2005 at 12:42:28PM +0200, Weber Matthias wrote:
> is their any php code example on how to store files (binary and ASCII) into a postgres db?

http://www.php.net/manual/en/functi...et-contents.php
http://www.php.net/manual/en/functi...scape-bytea.php
http://www.php.net/manual/en/functi...cape-string.php
http://www.php.net/manual/en/function.pg-query.php


p.
--
Paweł Bernat; uselessness' lover;
select'< asm'||chr(64)||'asm'
||'. '||'flynet'||chr(46)
||'pl>'as email;
Slowly and surely the unix crept up on the Nintendo user ...

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Volkan YAZICI

2005-06-15, 8:25 pm

Hi,

On 6/15/05, Weber Matthias <weber@faps.uni-erlangen.de> wrote:
> is their any php code example on how to store files (binary and
> ASCII) into a postgres db?


There's not so much difference between a data INSERT and file storage.
But, as a first step, you should decide on the way you want to store
the related data. Will it be stored on a normal table row (in a bytea
field) or as a large object? If you'll use LO, then you should refer
to its documentation for related functions and examples. But if you'll
use a normal bytea column, I'd strongly encourage you to use
parameters while inserting data. This is going to save you from CPU
and RAM wasting escaping routines, plus SQL-Injection attacks. (For
further performance tweaks, you can use binary mode while transmitting
data.)

Regards.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com