pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
faster way to display jpg-blobs?
3+ messages / 2 participants
[nested] [flat]

* faster way to display jpg-blobs?
@ 2001-03-18 05:22 Knut Suebert <knut.suebert@web.de>
  2001-03-18 07:11 ` Re: faster way to display jpg-blobs? Knut Suebert <knut.suebert@web.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Knut Suebert @ 2001-03-18 05:22 UTC (permalink / raw)
  To: pgsql-php

Hello,

I'm new to this list.

And I have the following question: is there a better/faster way than the
following to read jpeg-blobs out of the database and display them?

  if( $db->next_record() ){
    header("Content-Type: image/jpeg");
    $bild = $db->lo_read($db->f("oid"));
    header("Content-Length: 1024000"); // has to be calculated
    print($bild);
  }

where lo_read() is

  function lo_read($oid, $mode="r"){
    $this->connect();
    pg_exec($this->Link_ID, "begin"); // a must for blob-operations
    if( $lo_id = pg_loopen( $this->Link_ID, $oid, $mode ) ){
      $lo = pg_loread( $lo_id, 1024000 ); // has to be calculated
      pg_loclose($lo_id);
    }
    pg_exec($this->Link_ID, "end");
    return $lo; // empty leer, wenn auslesen gescheitert
  }

Because of the begin/end every picture on a page is loaded one after the
other, I fear. Not simultaneous as if there would be a direct <img
src='pic_N.jpg'> instead of <img src='pic.php?id=N'>.

Using blobs is a must IMHO, as viewing the pics should only be possible for
authorized people.

Thanks, bye,
Knut


  

     



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: faster way to display jpg-blobs?
  2001-03-18 05:22 faster way to display jpg-blobs? Knut Suebert <knut.suebert@web.de>
@ 2001-03-18 07:11 ` Knut Suebert <knut.suebert@web.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Knut Suebert @ 2001-03-18 07:11 UTC (permalink / raw)
  To: pgsql-php

Knut Suebert schrieb:

> And I have the following question: is there a better/faster way than the

>     header("Content-Length: 1024000"); // has to be calculated

has to be calculated, as i wrote. without an unexpected EOF the thing is
fast enough.

sorry,
knut



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: faster way to display jpg-blobs?
@ 2001-03-19 17:29 Brent R. Matzelle <bmatzelle@yahoo.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Brent R. Matzelle @ 2001-03-19 17:29 UTC (permalink / raw)
  To: pgsql-php

3/18/2001 7:22:35 AM, Knut Suebert <knut.suebert@web.de> wrote:
>Because of the begin/end every picture on a page is loaded one after the
>other, I fear. Not simultaneous as if there would be a direct <img
>src='pic_N.jpg'> instead of <img src='pic.php?id=N'>.

You can put a BEGIN/END around multiple queries to place all queries into one 
transaction block and thus rid yourself of some overhead.  Otherwise I do not 
know of any _faster_ way to download binary data from a database.  I would 
suggest that you place the images on the fs instead and provide a (VARCHAR) 
path to the file, but that option is dependent upon your web system.  

Brent




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2001-03-19 17:29 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-18 05:22 faster way to display jpg-blobs? Knut Suebert <knut.suebert@web.de>
2001-03-18 07:11 ` Knut Suebert <knut.suebert@web.de>
2001-03-19 17:29 Re: faster way to display jpg-blobs? Brent R. Matzelle <bmatzelle@yahoo.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox