note 34831 added to function.pg-escape-bytea
| From: | Mocha at rack1 dot php dot net | Date: | Thu, 07 Aug 2003 22:20:07 +0000 |
| Subject: | note 34831 added to function.pg-escape-bytea | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-53601@lists.php.net to get a copy of this message | ||
to unescape_bytea use stripcslashes(). If you need to escape bytea and don't have
pg_escape_bytea() function then use:
function escByteA($binData) {
/**
* \134 = 92 = backslash, \000 = 00 = NULL, \047 = 39 = Single Quote
*
* str_replace() replaces the searches array in order. Therefore, we must
* process the 'backslash' character first. If we process it last, it'll
* replace all the escaped backslashes from the other searches that came
* before.
*/
$search = array(chr(92), chr(0), chr(39));
$replace = array('\\\134', '\\\000', '\\\047');
$binData = str_replace($search, $replace, $binData);
return $binData;
//echo "<pre>$binData</pre>";
//exit;
}
----
Manual Page -- http://www.php.net/manual/en/function.pg-escape-bytea.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34831
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34831&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34831&report=yes