ID:               46249
 Updated by:       [EMAIL PROTECTED]
 Reported By:      hswong3i at gmail dot com
-Status:           Verified
+Status:           Assigned
 Bug Type:         PDO related
 Operating System: Debian
 PHP Version:      5.2.6
-Assigned To:      
+Assigned To:      felipe


Previous Comments:
------------------------------------------------------------------------

[2008-10-11 11:47:35] [EMAIL PROTECTED]

Oh sorry, you're right. I can reproduce it.

------------------------------------------------------------------------

[2008-10-11 06:47:47] hswong3i at gmail dot com

According to http://www.php.net/manual/en/pdo.lobs.php, using PDO for
BLOB INSERT/UPDATE should come with:
1. bindParam/bindColumn
2. PDO::PARAM_LOB
3. stream API, e.g. fopen(), fwrite(), rewind(), etc.

You may try to insert other value though you code snippet. The value
should also NOT able to insert into PostgreSQL...

The bug reproduction code in
http://drupal.org/node/316095#comment-1047830 is using pdo_pgsql
directly. The db_insert() used is just a fake clone of Drupal CVS HEAD
function with simplified programming logic.

------------------------------------------------------------------------

[2008-10-11 00:26:16] [EMAIL PROTECTED]

I can't reproduce using 5.3CVS:

$db = new PDO('pgsql:host=localhost dbname=test', 'foo', 'bar',
array(PDO::ATTR_STRINGIFY_FETCHES => TRUE));

$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (?)");
$stmt->execute(array(''));
var_dump($db->errorinfo());

$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES
(:foo)");
$x = '';
$stmt->bindParam(':foo', $x);
$stmt->execute();
var_dump($db->errorinfo());

$stmt = $db->query("INSERT INTO test_one_blob (blob1) VALUES ('')");
$stmt->execute();


teste=> select * from test_one_blob where blob1 is null;
 id | blob1 
----+-------
(0 registros)


Do you have tested using PDO directly, without Drupal's db_insert()?

------------------------------------------------------------------------

[2008-10-07 18:00:22] hswong3i at gmail dot com

Description:
------------
When pdo_pgsql working with:
  1. BLOB field,
  2. running INSERT/UPDATE queries, and
  3. BLOB value with empty string ''

It will always fill NULL into database and so result as buggy.
INSERT/UPDATE BLOB value with NULL will function correctly.

P.S. pdo_mysql is NOT buggy when running with similar programming
logic, empty string pass into database correctly. Tested with PHP5.2.6
and PHP5.3-dev, both are buggy.

Reproduce code:
---------------
Please refer to http://drupal.org/node/316095#comment-1047830 for more
information.

Expected result:
----------------
Empty string should fill into database correctly.

Actual result:
--------------
Empty string is now stored as NULL.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46249&edit=1

Reply via email to