note 24476 modified in function.pg-escape-bytea by danbrown
| From: | danbrown@php.net | Date: | Tue, 10 Nov 2009 15:39:27 +0000 |
| Subject: | note 24476 modified in function.pg-escape-bytea by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162707@lists.php.net to get a copy of this message | ||
if you need to change back bytea from the db to normal data, this will do that:
<?php
function pg_unescape_bytea($bytea) {
return eval("return \"".str_replace('$', '\\$',
str_replace('"', '\\"', $bytea))."\";");
}
// use like this
$rs = pg_query($conn, "SELECT image from images LIMIT 1");
$image = pg_unescape_bytea(pg_fetch_result($rs, 0, 0));
?>
/Tobias
--was--
if you need to change back bytea from the db to normal data, this will do that:
function pg_unescape_bytea($bytea) {
return eval("return \"".str_replace('$', '\\$',
str_replace('"', '\\"', $bytea))."\";");
}
// use like this
$rs = pg_query($conn, "SELECT image from images LIMIT 1");
$image = pg_unescape_bytea(pg_fetch_result($rs, 0, 0));
/Tobias
http://php.net/manual/en/function.pg-escape-bytea.php