PHP 8.5.0 Alpha 4 available for testing

Voting

: max(nine, two)?
(Example: nine)

The Note You're Voting On

ynzhang from lakeheadu of ca
16 years ago
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:

<?php
$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

<< Back to user notes page

To Top