1

我用 Zend Framework + Postgres 写了一个网站。在 PostgreSQL 中有这张表:

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

我打算在哪里存储图像数据。但是当我尝试从表(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']));

我收到类似的东西:

Resource id #12_

但不是包含数据。

我如何(使用Zend_Db_Select)接收这些数据,而不是 Resource id #129?对不起,我的英语不好 ...

4

2 回答 2

3

如果问题仍然存在,请替换此行:

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

这样:

die(fpassthru($res['thumbnail']))
于 2012-11-19T19:56:31.337 回答
0
$stream = $res['thumbnail'];
@unlink($pathFile);
touch($pathFile);
while (($buffer = (fgets($stream, 8192))) !== false) {
    file_put_contents($pathFile, $buffer, FILE_APPEND);
}
于 2012-11-28T16:47:27.403 回答