Zend Framework

Zend_Db_Statement_Mysqli destructor should check whether close() is called

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.0.3
  • Fix Version/s: None
  • Component/s: Zend_Db
  • Labels:
    None
  • Fix Version Priority:
    Nice to Have

Description

You should call close() method before reference has gone if you use Zend_Db_Statement_Mysqli statement.

This should be noted on it.
http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.adapter-notes

If you do not call, you may receive a message at next use of the database.
The message is "Commands out of sync; You can't run this command now".
This will cause a problem you hard to find out.

The destructor check could avoid the issue.

The Statement sample something like this.

$statement = $select->query();
try {
    $data = $statement->fetchAll();
    // ...

    if (method_exists($statement, 'close')) {
        $statement->close();
    }
} catch (Exception $e) {
    try {
        // Mysqli
        if (method_exists($statement, 'close')) {
            $statement->close();
        }
    } catch (Exception $e) {
        // ignore close error
    }
    throw $e;
}

Activity

Hide
Wil Sinclair added a comment -

Please categorize/fix as needed.

Show
Wil Sinclair added a comment - Please categorize/fix as needed.
Hide
Wil Sinclair added a comment -

Ralph, please verify and update docs as appropriate.

Show
Wil Sinclair added a comment - Ralph, please verify and update docs as appropriate.
Hide
Ralph Schindler added a comment -

Will evaluate within 2 weeks

Show
Ralph Schindler added a comment - Will evaluate within 2 weeks
Hide
Satoru Yoshida added a comment -

brushup the description

Show
Satoru Yoshida added a comment - brushup the description
Hide
Satoru Yoshida added a comment -

Does this issue depends on ZF-3984?
I think this could be solved if ZF-3984 would be cleared.

Show
Satoru Yoshida added a comment - Does this issue depends on ZF-3984? I think this could be solved if ZF-3984 would be cleared.
Hide
Satoru Yoshida added a comment -

In my search, it does not depend on ZF-3984.
Only guide may be needed.

Show
Satoru Yoshida added a comment - In my search, it does not depend on ZF-3984. Only guide may be needed.
Hide
twk added a comment -

i'm not sure if not-calling close causes a big issue with the current release. if not, the destructor does not have to check.

Show
twk added a comment - i'm not sure if not-calling close causes a big issue with the current release. if not, the destructor does not have to check.

People

Vote (2)
Watch (2)

Dates

  • Due:
    Created:
    Updated:
    Resolved: