Issues

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

Patch which adds a second parameter to Zend_Db_Statement_Mysqli_Exception to track error number as well as error message

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.

This issue has gone unaddressed for too long. I'm re-assigning to Ralph for re-evaluation and categorization.

Will address this issue within 2 weeks. Find me on IRC within the next week.

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.

Assigning to Josh Butts. Setting priority to "Minor". Setting "Nice to Have" in the "Next Mini Release"

Updated patch based on the original but doesn't patch the exception class

attached test case patch

Please review. If you approve I can go ahead and commit these revisions.

Patch looks good. As noted in our discussion, add @group ZF-3216 to the docblock. Commit to trunk, merge to 1.9 branch.

Thanks!

Fixed in r17692, merged to 1.9 in r17693