note 96311 added to pdo.lobs
| From: | JeremyCook at osu1 dot php dot net | Date: | Fri, 19 Feb 2010 21:31:17 +0000 |
| Subject: | note 96311 added to pdo.lobs | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166196@lists.php.net to get a copy of this message | ||
There seems to be a bug that affects example 1 above. PDO::PARAM_LOB when used with
pdo::bindColumn() is supposed to return a stream but it returns a string. Passing this string to
fpassthru() then triggers an error with the message 'supplied argument is not a valid stream
resource'. This has been reported in bug #40913. The work around is to do the following:
$stmt = $db->prepare("select contenttype, imagedata from images where id=?");
$stmt->execute(array($_GET['id']));
$stmt->bindColumn(1, $type, PDO::PARAM_STR, 256);
$stmt->bindColumn(2, $lob, PDO::PARAM_LOB);
$stmt->fetch(PDO::FETCH_BOUND);
header("Content-Type: $type");
echo($lob);
Since the browser is expecting an image after the call to header() writing the string representation
of the binary output with echo() has the same affect as calling fpassthru().
----
Server IP: 66.207.199.35
Probable Submitter: 65.93.32.66
----
Manual Page -- http://www.php.net/manual/en/pdo.lobs.php
Edit -- https://master.php.net/note/edit/96311
Del: integrated -- https://master.php.net/note/delete/96311/integrated
Del: useless -- https://master.php.net/note/delete/96311/useless
Del: bad code -- https://master.php.net/note/delete/96311/bad+code
Del: spam -- https://master.php.net/note/delete/96311/spam
Del: non-english -- https://master.php.net/note/delete/96311/non-english
Del: in docs -- https://master.php.net/note/delete/96311/in+docs
Del: other reasons-- https://master.php.net/note/delete/96311
Reject -- https://master.php.net/note/reject/96311
Search -- https://master.php.net/manage/user-notes.php