Re: [PHP-DB] can i display an image _directly_ from postgres db storage?

2004-11-02 Thread Joshua D. Drake
Jason Wong wrote:
On Tuesday 02 November 2004 03:36, P. George wrote:
 

i know that postgres has a raw binary datatype called bytea for storing
pictures and whatnot, but i'm having trouble finding an example of
displaying an image on a web page with php that is pulled directly from
the database?
is this possible?
   

You probably don't want to use bytea as it will use a lot of
ram for larger images.
Instead you will want to look at large objects. The functions
you want are:
*pg_loreadall()* 	*pg_lo_read_all()* 
http://www.php.net/manual/en/function.pg-lo-read-all.php
*pg_locreate()* 	*pg_lo_create()* 
http://www.php.net/manual/en/function.pg-lo-create.php
*pg_lounlink()* 	*pg_lo_unlink()* 
http://www.php.net/manual/en/function.pg-lo-unlink.php
*pg_loopen()* 	*pg_lo_open()* 
http://www.php.net/manual/en/function.pg-lo-open.php
*pg_loclose()* 	*pg_lo_close()* 
http://www.php.net/manual/en/function.pg-lo-close.php
*pg_loread()* 	*pg_lo_read()* 
http://www.php.net/manual/en/function.pg-lo-read.php
*pg_lowrite()* 	*pg_lo_write()* 
http://www.php.net/manual/en/function.pg-lo-write.php
*pg_loimport()* 	*pg_lo_import()* 
http://www.php.net/manual/en/function.pg-lo-import.php
*pg_loexport()* 	*pg_lo_export()* 
http://www.php.net/manual/en/function.pg-lo-export.php


Sincerely,
Joshua D. Drake

Yes.
 

if so, how?
   

Tutorials that shows how to upload and store image/binary files in a database 
also usually shows how to retrieve them (and in the case of images, also how 
to display them).

One function you'll find useful is
 imagecreatefromstring()
 


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - [EMAIL PROTECTED] - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DB] can i display an image _directly_ from postgres db storage?

2004-11-02 Thread Robby Russell
On Mon, 2004-11-01 at 21:36 -0600, P. George wrote:
 i know that postgres has a raw binary datatype called bytea for storing 
 pictures and whatnot, but i'm having trouble finding an example of 
 displaying an image on a web page with php that is pulled directly from 
 the database?
 
 is this possible?

This example uses large objects, you can try to use the same logic and
use the bytea field.

http://blog.planetargon.com/index.php?/archives/27_Displaying_image_from_PostgreSQL_large_object_with_PHP.html


-- 
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting  Development
*--- Now supporting PHP5 ---
/


signature.asc
Description: This is a digitally signed message part


RE: [PHP-DB] can i display an image _directly_ from postgres db storage?

2004-11-01 Thread Mike
Philip,

Typically, it's infinitely more performance-friendly to simply store your
files on the hard disk and use the database to refer to that location.

For instance, assume your root web dir is /www. Inside there you have an
/images directory. 

If you religiously put all files inside of /images you can store the file
name inside the DB and simply have your code output the proper HTML. Or, if
you have to actually do image processing, you can have your code query the
DB and then read the file into an image handler for GD or whatever you're
using to do the processing.

Either way, it's usually encouraged not to store BLOBs whenever possible due
to the performance hit that's usually associated with that.

-M



-Original Message-
From: P. George [mailto:[EMAIL PROTECTED] 
Sent: Monday, November 01, 2004 10:36 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] can i display an image _directly_ from postgres db
storage?

i know that postgres has a raw binary datatype called bytea for storing 
pictures and whatnot, but i'm having trouble finding an example of 
displaying an image on a web page with php that is pulled directly from 
the database?

is this possible?

if so, how?

thanks.

- philip

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] can i display an image _directly_ from postgres db storage?

2004-11-01 Thread P. George
Typically, it's infinitely more performance-friendly to simply store 
your
files on the hard disk and use the database to refer to that location.

For instance, assume your root web dir is /www. Inside there you have 
an
/images directory.

If you religiously put all files inside of /images you can store the 
file
name inside the DB and simply have your code output the proper HTML. 
Or, if
you have to actually do image processing, you can have your code query 
the
DB and then read the file into an image handler for GD or whatever 
you're
using to do the processing.

Either way, it's usually encouraged not to store BLOBs whenever 
possible due
to the performance hit that's usually associated with that.

although it's a kind gesture to worry about my site's performance, i 
would still like to find out how to do this and maybe test the 
performance myself.

also, note that i'd like to be able to do this without the use of 
apache's cocoon database reader, as i doubt my lame webhost would 
install that for me.

- philip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] can i display an image _directly_ from postgres db storage?

2004-11-01 Thread Jason Wong
On Tuesday 02 November 2004 03:36, P. George wrote:
 i know that postgres has a raw binary datatype called bytea for storing
 pictures and whatnot, but i'm having trouble finding an example of
 displaying an image on a web page with php that is pulled directly from
 the database?

 is this possible?

Yes.

 if so, how?

Tutorials that shows how to upload and store image/binary files in a database 
also usually shows how to retrieve them (and in the case of images, also how 
to display them).

One function you'll find useful is

  imagecreatefromstring()

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
There are a lot of lies going around and half of them are true.
  -- Winston Churchill
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] can i display an image _directly_ from postgres db storage?

2004-11-01 Thread P. George
Tutorials that shows how to upload and store image/binary files in a 
database
also usually shows how to retrieve them (and in the case of images, 
also how
to display them).

One function you'll find useful is
  imagecreatefromstring()

thanks.
i found an example for uploading an image into the proper database 
field, which ***seems*** to have worked.

and i found another example for pulling it back out to use directly in 
html code:

?php
	$dbconn = pg_connect(host=1.2.3.4 port=5432 dbname=mydb user=myname 
password=mypass);
	$result = pg_exec($dbconn, SELECT $image FROM thetable where 
name='$name');
	$image = stripcslashes(pg_result($result, 0, 0));
	header(content-type: image/gif);
	echo $image;
?

... BUT it's giving me the following error:
Parse error: parse error, unexpected T_STRING in /myfolder/gif.php on 
line 5

that's the header() line, but what could the problem be?
thanks.
- philip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] can i display an image _directly_ from postgres db storage?

2004-11-01 Thread P. George
	$result = pg_exec($dbconn, SELECT $image FROM thetable where 
name='$name');
nevermind.  i had a missing double-quote on this line.  works great now.
thanks.
- philip
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php