|  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
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
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2007-10-10 13:03 UTC] remi dot lanvin at bsocom dot com
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');

Expected result:
An array of serialized strings.

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


Add a Patch

Pull Requests

Add a Pull Request


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]
Please try using this CVS snapshot:
For Windows (zip):

For Windows (installer):

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]
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]
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-2021 The PHP Group
All rights reserved.
Last updated: Fri May 14 02:01:23 2021 UTC