note 89036 added to function.pg-escape-bytea

From: Date: Wed, 18 Feb 2009 21:44:48 +0000
Subject: note 89036 added to function.pg-escape-bytea
Groups: php.notes 
Request: Send a blank email to php-notes+get-150828@lists.php.net to get a copy of this message
The reason pg_unescape_bytea() do not exactly reproduce the binary data created by pg_escape_bytea() is because the backslash \ and single quote ' are double escaped by the pg_escape_bytea() function. This will lead to image seems corrupted when retrieve from the bytea field. The proper way to escape&unescape a binary string into a PG bytea field as follow: $escaped_data = str_replace(array("\\\\", "''"), array("\\", "'"), pg_escape_bytea($data)); /* and later unescape the escaped data from the bytea field with following to get the original binary data */ $original_data = pg_unescape_bytea($escaped_data)); more details at: http://archives.postgresql.org/pgsql-php/2007-02/msg00014.php ---- Server IP: 66.207.199.35 Probable Submitter: 96.52.26.173 ---- Manual Page -- http://www.php.net/manual/en/function.pg-escape-bytea.php Edit -- https://master.php.net/note/edit/89036 Del: integrated -- https://master.php.net/note/delete/89036/integrated Del: useless -- https://master.php.net/note/delete/89036/useless Del: bad code -- https://master.php.net/note/delete/89036/bad+code Del: spam -- https://master.php.net/note/delete/89036/spam Del: non-english -- https://master.php.net/note/delete/89036/non-english Del: in docs -- https://master.php.net/note/delete/89036/in+docs Del: other reasons-- https://master.php.net/note/delete/89036 Reject -- https://master.php.net/note/reject/89036 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#150828) next »