ZF-2607: Add method to Zend_Db_Adapter_Abstract to retrieve last used statement object
Description
Add method to Zend_Db_Adapter_Abstract to retrieve last used statement object.
This would allow users to call the errorCode and errorInfo PDO methods if a query fails and additional infos are needed.
Comments
Posted by Ota Mares (ota) on 2008-02-09T19:27:16.000+0000
Modified Zend_Db_Adapter_Abstract class with new method getStatement.
The PDO statement gets safed when the query method is executed (see line 415).
Posted by Ota Mares (ota) on 2008-02-09T19:31:17.000+0000
Fixed typo ;)
Posted by Wil Sinclair (wil) on 2008-03-25T20:43:55.000+0000
Please categorize/fix as needed.
Posted by Benjamin Eberlei (beberlei) on 2008-09-05T11:30:19.000+0000
It would also be possible to add the PDOStatement/Exception/ErrorInfo as additional parameters to the statement exception. and make it retrievable by additional getPDOException method or something.
Posted by Wil Sinclair (wil) on 2009-01-06T10:50:41.000+0000
No action on this issue for too long. I'm reassigning to Ralph for re-evaluation and categorization.
Posted by Ralph Schindler (ralph) on 2009-01-10T11:12:13.000+0000
Will evaluate within 2 weeks
Posted by Ralph Schindler (ralph) on 2009-08-27T15:55:39.000+0000
Keeping a reference to the last statement has the potential of creating a memory leak in Zend_Db, since Zend_Db_Adapter::query() actually gives you the statement, its the job of the developer to keep track of it.
There should be no relation between the adapter and the statement. Please reopen if you have a use case that might be considered.
Posted by Ota Mares (ota) on 2009-08-28T02:47:09.000+0000
Please look at the following code example. There is no other way to check what kind of error i have than comparing the string value of the exception (And thats an ugly solution to solve it). The Zend_Db_Adapter_Abstract::insert() method does not return the statement object and there is no way to retrieve it, thats why i asked for a get method.