1

I wrote a website with Zend Framework + Postgres. In PostgreSQL there is this table:

create table images(
    id                      serial,
    title                   TEXT DEFAULT '',
    thumbnail               bytea NOT NULL,
    original                bytea NOT NULL,
    PRIMARY KEY(id)
);

Where I'm planning to store image data. But when I try to receive anything from the table (select thumbnail from images where id = $id):

$table = $mapper->getDbTable();
$select = $table->select();
$select->from($table,array('thumbnail'));
$select->where('id = ?',$id);

$res = $table->fetchRow($select);
die(print_r($res['thumbnail']));

I receive something like:

Resource id #12_

but not the containing data.

How could I (using Zend_Db_Select) receive this data, but not a Resource id #129? Sorry for my bad english ...

ByteNudger
  • 1,545
  • 5
  • 29
  • 37

2 Answers2

3

if the problem remains, replace this line:

die(print_r($res['thumbnail']));

by this:

die(fpassthru($res['thumbnail']))
0
$stream = $res['thumbnail'];
@unlink($pathFile);
touch($pathFile);
while (($buffer = (fgets($stream, 8192))) !== false) {
    file_put_contents($pathFile, $buffer, FILE_APPEND);
}
eliiq
  • 1
  • 2
    Welcome to Stack Overflow! Rather than only post a block of code, please *explain* why this code solves the problem posed. Without an explanation, this is not an answer. – Martijn Pieters Nov 28 '12 at 17:06