ZF-3216: Zend_Db_Adapter_Mysqli does not provide a proper way to catch MySQL error codes.
Description
Correct me if I'm wrong but I found no possible way to catch MySQL error codes when using Zend_Db_Adapter_Mysqli. All exceptions are thrown without attaching error code.
Affected methods inside Zend_Db_Statement_Mysqli are: public function _prepare() public function _execute()
An easy/dirty fix would be replacing: throw new Zend_Db_Statement_Mysqli_Exception("Mysqli prepare error: " . $mysqli->error); ... with: throw new Zend_Db_Statement_Mysqli_Exception("Mysqli prepare error: " . $mysqli->error, $mysqli->errno); ...
Comments
Posted by Mark Evans (sparky) on 2008-08-17T03:15:39.000+0000
Patch which adds a second parameter to Zend_Db_Statement_Mysqli_Exception to track error number as well as error message
Posted by Till Klampaeckel (till) on 2008-11-01T07:02:44.000+0000
Since the patch has not been applied, does that mean that "next minor release" status can be disregarded?
I'm desperately looking for this fix as well.
Posted by Wil Sinclair (wil) on 2009-01-06T14:34:28.000+0000
This issue has gone unaddressed for too long. I'm re-assigning to Ralph for re-evaluation and categorization.
Posted by Ralph Schindler (ralph) on 2009-01-10T12:25:55.000+0000
Will address this issue within 2 weeks. Find me on IRC within the next week.
Posted by Josh Butts (jimbojsb) on 2009-08-17T20:24:41.000+0000
The patch above addresses the issue when applied to the current ZF trunk. Also, I see no need to patch the exception class, as the base class is already expecting a numeric error code.
Posted by Ralph Schindler (ralph) on 2009-08-17T20:30:08.000+0000
Assigning to Josh Butts. Setting priority to "Minor". Setting "Nice to Have" in the "Next Mini Release"
Posted by Josh Butts (jimbojsb) on 2009-08-18T19:31:22.000+0000
Updated patch based on the original but doesn't patch the exception class
Posted by Josh Butts (jimbojsb) on 2009-08-18T19:31:45.000+0000
attached test case patch
Posted by Josh Butts (jimbojsb) on 2009-08-18T19:32:55.000+0000
Please review. If you approve I can go ahead and commit these revisions.
Posted by Ralph Schindler (ralph) on 2009-08-19T07:46:04.000+0000
Patch looks good. As noted in our discussion, add @group ZF-3216 to the docblock. Commit to trunk, merge to 1.9 branch.
Thanks!
Posted by Josh Butts (jimbojsb) on 2009-08-20T09:37:50.000+0000
Fixed in r17692, merged to 1.9 in r17693