You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
i've just track down a nasty problem with libpq used in this php build.
today, libpq is version is 8.2.23
if we use this version with postgresql 9.3.x , bytea decoding is returned as escaped version.
It seems that this old libpq version doesn't handle cleanly bytea conversions .
here is a quick test that show the problem and a solution.
CREATE TABLE bintest
(
id serial NOT NULL,
data bytea,
CONSTRAINT pkok PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
<?php
//DATA insertion
$dbh = new PDO("pgsql:dbname=cmf;host=localhost", 'xav');
$thebytes = file_get_contents('source.jpg');
$sth = $dbh->prepare("INSERT INTO bintest ( data ) VALUES (:content)");
$sth->bindParam(':content', $thebytes, PDO::PARAM_LOB);
$sth->execute();
//DATA Reading
//If we use this line, everything is ok
$dbh->query("SET bytea_output=escape");
$sth = $dbh->prepare("SELECT data FROM bintest WHERE id = 1");
$sth->execute();
$content = $sth->fetchColumn();
file_put_contents('test.jpg', $content);
thanks
Xavier
The text was updated successfully, but these errors were encountered:
Hi,
i've just track down a nasty problem with libpq used in this php build.
today, libpq is version is 8.2.23
if we use this version with postgresql 9.3.x , bytea decoding is returned as escaped version.
It seems that this old libpq version doesn't handle cleanly bytea conversions .
here is a quick test that show the problem and a solution.
thanks
Xavier
The text was updated successfully, but these errors were encountered: