Zend Framework

Zend_Db_Adapter_Mysqli does not provide a proper way to catch MySQL error codes.

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.5.2
  • Fix Version/s: 1.9.2
  • Labels:
    None
  • Fix Version Priority:
    Nice to Have

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);
...

  1. ZF-3216.patch
    17/Aug/08 3:15 AM
    3 kB
    Mark Evans
  2. ZF-3216.statement_mysqli.patch
    18/Aug/09 7:31 PM
    1 kB
    Josh Butts
  3. ZF-3216.test.patch
    18/Aug/09 7:31 PM
    0.9 kB
    Josh Butts

Issue Links

Activity

Hide
Mark Evans added a comment -

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

Show
Mark Evans added a comment - Patch which adds a second parameter to Zend_Db_Statement_Mysqli_Exception to track error number as well as error message
Hide
Till Klampaeckel added a comment -

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.

Show
Till Klampaeckel added a comment - 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.
Hide
Wil Sinclair added a comment -

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

Show
Wil Sinclair added a comment - This issue has gone unaddressed for too long. I'm re-assigning to Ralph for re-evaluation and categorization.
Hide
Ralph Schindler added a comment -

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

Show
Ralph Schindler added a comment - Will address this issue within 2 weeks. Find me on IRC within the next week.
Hide
Josh Butts added a comment -

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.

Show
Josh Butts added a comment - 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.
Hide
Ralph Schindler added a comment -

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

Show
Ralph Schindler added a comment - Assigning to Josh Butts. Setting priority to "Minor". Setting "Nice to Have" in the "Next Mini Release"
Hide
Josh Butts added a comment -

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

Show
Josh Butts added a comment - Updated patch based on the original but doesn't patch the exception class
Hide
Josh Butts added a comment -

attached test case patch

Show
Josh Butts added a comment - attached test case patch
Hide
Josh Butts added a comment -

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

Show
Josh Butts added a comment - Please review. If you approve I can go ahead and commit these revisions.
Hide
Ralph Schindler added a comment -

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

Thanks!

Show
Ralph Schindler added a comment - Patch looks good. As noted in our discussion, add @group ZF-3216 to the docblock. Commit to trunk, merge to 1.9 branch. Thanks!
Hide
Josh Butts added a comment -

Fixed in r17692, merged to 1.9 in r17693

Show
Josh Butts added a comment - Fixed in r17692, merged to 1.9 in r17693

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
1h
Original Estimate - 1 hour
Remaining:
30m
Time Spent - 30 minutes Remaining Estimate - 30 minutes
Logged:
30m
Time Spent - 30 minutes Remaining Estimate - 30 minutes