php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42916 FETCH_SERIALIZE doesn't work
Submitted: 2007-10-10 13:03 UTC Modified: 2008-11-18 01:00 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: remi dot lanvin at bsocom dot com Assigned:
Status: No Feedback Package: Documentation problem
PHP Version: 5.2.4 OS: Linux 2.6.17.8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: remi dot lanvin at bsocom dot com
New email:
PHP Version: OS:

 

 [2007-10-10 13:03 UTC] remi dot lanvin at bsocom dot com
Description:
------------
PDO::FETCH_SERIALIZE doesn't provide a serialized string.

Reproduce code:
---------------
class MyClass { }

$dbh = new PDO($dsn, $user, $password);
$results = $dbh->query($sql);
$results->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_SERIALIZE, 'MyClass');
print_r($results->fetchAll());

Expected result:
----------------
An array of serialized strings.

Actual result:
--------------
An array of unserialized MyClass objects (similar as with FETH_CLASS alone).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-10-10 13:51 UTC] remi dot lanvin at bsocom dot com
If I repeat the fetch mode as an argument to fetchAll(), I get the following error :

SQLSTATE[HY000]: General error: cannot unserialize class

Reproduce code :

$results->setFetchMode(PDO::FETCH_CLASS | PDO::FETCH_SERIALIZE, 'MyClass');
print_r($results->fetchAll(PDO::FETCH_CLASS | PDO::FETCH_SERIALIZE));
 [2007-10-11 21:48 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

Works in CVS.
 [2007-10-12 14:43 UTC] remi dot lanvin at bsocom dot com
I'm still unable to get FETCH_SERIALIZE working with CVS version.

I get exactly the same results :
- with setFetchMode the returned array is like with FETCH_CLASS alone ;
- with fetchAll (or fetch) I get the "cannot unserialize class" error.

Additionnaly, according to the documentation, FETCH_SERIALIZE works as FETCH_INTO. However, I'm confused as setFetchMode says "SQLSTATE[HY000]: General error: PDO::FETCH_SERIALIZE can only be used together with PDO::FETCH_CLASS".
 [2007-10-12 18:17 UTC] mj@php.net
With PHP 5.3 (latest CVS) I can reproduce the issue.  With HEAD however an empty array is returned.  (Identical configurations for both builds.)
 [2008-11-10 11:05 UTC] vrana@php.net
What exactly should be documented?
 [2008-11-18 01:00 UTC] doc-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 15:01:29 2024 UTC