#42916 [Fbk->Opn]: FETCH_SERIALIZE doesn't work
| From: | remi dot lanvin at bsocom dot com | Date: | Fri, 12 Oct 2007 14:43:42 +0000 |
| Subject: | #42916 [Fbk->Opn]: FETCH_SERIALIZE doesn't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-118474@lists.php.net to get a copy of this message | ||
ID: 42916
User updated by: remi dot lanvin at bsocom dot com
Reported By: remi dot lanvin at bsocom dot com
-Status: Feedback
+Status: Open
Bug Type: PDO related
Operating System: Linux 2.6.17.8
PHP Version: 5.2.4
New Comment:
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".
Previous Comments:
------------------------------------------------------------------------
[2007-10-11 21:48:37] 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-10 13:51:00] 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-10 13:03:54] 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).
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42916&edit=1