|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-11-22 20:57 UTC] f dot engelhardt at 21torr dot com
Description:
------------
I tried to write binary data into a postgresql table, that work, but i can not get this data out the table anymore.
Reproduce code:
---------------
<?php
$dbh = new PDO('pgsql:host=localhost;dbname=test','root','fo0224');
$q = 'SELECT data FROM foobar';
$stmt = $dbh->prepare($q);
if ($stmt)
{
$stmt->bindColumn('DATA',$sData);
if (!$stmt->execute())
{
print_r($stmt->errorInfo());
die('DAMN');
}
if (!$stmt->fetch(PDO::FETCH_BOUND))
{
print_r($stmt->errorInfo());
die('DAMN');
}
header('Content-Type: image/jpeg');
echo $sData;
} else {
print_r($dbh->errorInfo());
}
?>
Table foobar only has a bytea column named data
Expected result:
----------------
should display the image
Actual result:
--------------
the php-process does not do anything, the browser waits for an answer (i waited 5 minutes, but nothing happened)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
Exact the same script (replacing pgsql by mysql in the new PDO line) it works with mysql. I also tried it with CLI, the same error. And i found out another bug. I tried to insert data into the table with pdo into a postgresql database, but there are only some bytes inserted, not all. Script: <?php $dbh = new PDO('pgsql:host=localhost;dbname=test','root','fo0224'); $sData = file_get_contents('/home/bowman/.fluxbox/backgrounds/NVA-91.jpg'); $q = 'INSERT INTO foobar (data) VALUES (:data)'; $stmt = $dbh->prepare($q); if ($stmt) { $stmt->bindParam(':data',$sData); if (!$stmt->execute()) { print_r($stmt->errorInfo()); die('DAMN'); } //header('Content-Type: image/jpeg'); echo $sData; flush(); exit; } else { print_r($dbh->errorInfo()); } ?> This script is working with MySQL, but not with PostgresqlIt works, if i specify PDO::PARAM_LOB with the bindParam() call in the insert script: $stmt->bindParam(':data',$sData,PDO::PARAM_LOB); I am not sure, if it should work without this, but it is working on postgresql if i do it like this. It also works with mysql, but that was working also without the PDO::PARAM_LOB parameter. So my question is: Is it desired that binary data can be inserted into a table without PDO::PARAM_LOB or not?