ID: 35338
Updated by: [EMAIL PROTECTED]
Reported By: f dot engelhardt at 21torr dot com
-Status: Open
+Status: Assigned
Bug Type: PDO related
Operating System: Linux
PHP Version: 5CVS-2005-11-22 (CVS)
-Assigned To:
+Assigned To: wez
New Comment:
Assigned to the maintainer.
Previous Comments:
------------------------------------------------------------------------
[2005-11-23 12:28:51] f dot engelhardt at 21torr dot com
Sorry, i forgot to give you another hint:
The data in the postgresql database in the first script was added with
the pg_-functions into a bytea field.
As explained some minutes ago, inserting binary data into a bytea field
in postgres via pdo failes with no error output.
Maybe i am using the wrong datatype for binary data in postgres, but i
only found bytea for binary puroses.
------------------------------------------------------------------------
[2005-11-23 12:25:07] f dot engelhardt at 21torr dot com
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 Postgresql
------------------------------------------------------------------------
[2005-11-22 22:36:40] [EMAIL PROTECTED]
Are you able to reproduce it with something different than PgSQL?
Sqlite, for example?
Are you able to reproduce it with PHP CLI?
------------------------------------------------------------------------
[2005-11-22 20:57:09] 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)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35338&edit=1