ZF-10866: Zend_Db_Statement->setFetchMode with Zend_Db::FETCH_CLASS and PDO adapter throws exception on newer PHP versions
Description
PHP right now (5.3.3 presents this behaviour, 5.2.14 was not) requires 2 or 3 arguments to function PDOStatement->setFetchMode, which is stated in http://php.net/manual/en/… Unfortunately, Zend_Db_Statement_Pdo's setFetchMode provides only one. This crashes every code that uses setFetchMode with FETCH_CLASS when using PDO. This effectively renders Zend_Db_Select->query() useless, as it calls setFetchMode unconditionally, and probably affects a lot of other methods as well.
Note: Tested with 1.11.1 and 1.8.4 but probably affects everything in between and a lot before 1.8.4.
Priority blocker, because any code using it will refuse to work after PHP upgrade.
Comments
Posted by Waclaw Schiller (torinthiel) on 2010-12-23T13:57:12.000+0000
This issue was already reported, but with less background, and was closed with reason not related to original issue.
Posted by Pádraic Brady (padraic) on 2011-08-28T09:51:30.000+0000
Hi Ralph,
Seems like a valid Blocker issue on PHP 5.3. Any chance you could implement the fix above, or some kind of passthrough on other methods accepting the fetch mode directly for next minor?
Posted by Adam Lundrigan (adamlundrigan) on 2012-02-24T00:47:22.000+0000
Confirmed. Test Case:
Result:
Posted by Adam Lundrigan (adamlundrigan) on 2012-02-24T01:16:16.000+0000
Attached possible fix + unit tests. Alters signature of {{Zend_Db_Statement_Pdo::setFetchMode}}, a change which may (?) also need to be made in it's superclass.
Posted by Adam Lundrigan (adamlundrigan) on 2012-02-24T03:04:11.000+0000
I've attached a second patch (ZF-10866_V2.patch) which implements the same functionality without changing the existing method signature. This new implementation is much less code, but doesn't appear to work for PDO::FETCH_INTO (object comes out empty)
Posted by Adam Lundrigan (adamlundrigan) on 2012-05-17T18:25:07.000+0000
Zend_Db does not support using PDO fetch mode constants directly. Please see the reasons stated in @ZF-9728 and ZF-3470.