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

 ID:                 53756
 Updated by:         [email protected]
 Reported by:        admin at webdesignforall dot net
 Summary:            Unable to insert serialized objects with private
                     variables in pgsql
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            PDO related
 Operating System:   Ubuntu 10.04 32 bit
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Serialized content of private/protected properties contain \0 inside the


generated string. This causes truncation, to avoid it you need to change
the 

column type to binary and write data as a binary string.


Previous Comments:
------------------------------------------------------------------------
[2011-01-15 11:27:21] admin at webdesignforall dot net

Description:
------------
Using php 5.3.5 with pdo_pgsql and pgsql 9.0.2 when inserting serialized
objects 

that contain private variables the serialized string is truncate as soon
as it 

hits the private variable.



Objects that do not contain private variables work fine.



When using the pdo_mysql driver it also works fine.

Test script:
---------------
<?php

class foo{

private $_var;

}

$foo=serialize(new foo());

$q=new PDO("pgsql:host=localhost;dbname=testdb","root","");

$q->exec('CREATE TABLE test (data TEXT)');

$s=$q->prepare("INSERT INTO test VALUES(?)");

$s->bindValue(1,$foo);

$s->execute();

$s=$q->query("SELECT * FROM test");

var_dump($s->fetchAll(PDO::FETCH_ASSOC),$foo);

Expected result:
----------------
array(1) {

  [0]=>

  array(1) {

    ["data"]=>

    string(32) "O:3:"foo":1:{s:9:"foo_var";N;}"

  }

}

string(32) "O:3:"foo":1:{s:9:"foo_var";N;}"



Actual result:
--------------
array(1) {

  [0]=>

  array(1) {

    ["data"]=>

    string(18) "O:3:"foo":1:{s:9:""

  }

}

string(32) "O:3:"foo":1:{s:9:"foo_var";N;}"




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



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

Reply via email to