note 101881 added to pdo.lobs
| From: | kozy_ligh at yahoo dot com | Date: | Sat, 15 Jan 2011 19:21:28 +0000 |
| Subject: | note 101881 added to pdo.lobs | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175790@lists.php.net to get a copy of this message | ||
Problem with saving blob from DB2 DB to file. Tried:
try{
$stmt = $db->prepare($QSql);
$stmt->execute();
$res = $stmt->fetchAll( PDO::FETCH_ASSOC );
}
catch (PDOException $e)
{
echo $e->getMessage();
}
$FileName = $res[0]['DOKU_KBESEDA'];
$createFile = './Datoteke/'.$FileName;
$content = stream_get_contents( $res[0]['DOKU_DOKUMENT'] );
file_put_contents( $createFile, $content );
the file gets created but it is empty.
What did work is selecting it as a LOB and doing this with the string it returned:
function hextostr($x) {
$s='';
foreach(explode("\n",trim(chunk_split($x,2))) as $h) $s.=chr(hexdec($h));
return($s);
}
This takes too much ram tho, so big files are a no go.
Any help is very apriciated!
With regards,
Marko
kozy_ligh@yahoo.com
----
Server IP: 69.147.83.197
Probable Submitter: 82.192.55.135
----
Manual Page -- http://www.php.net/manual/en/pdo.lobs.php
Edit -- https://master.php.net/note/edit/101881
Del: integrated -- https://master.php.net/note/delete/101881/integrated
Del: useless -- https://master.php.net/note/delete/101881/useless
Del: bad code -- https://master.php.net/note/delete/101881/bad+code
Del: spam -- https://master.php.net/note/delete/101881/spam
Del: non-english -- https://master.php.net/note/delete/101881/non-english
Del: in docs -- https://master.php.net/note/delete/101881/in+docs
Del: other reasons-- https://master.php.net/note/delete/101881
Reject -- https://master.php.net/note/reject/101881
Search -- https://master.php.net/manage/user-notes.php