Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test if table was updated in Zend Framework?

When user opens a form to modify a record, but instead of changing information, he just clicks the Update button. Which causes the update() function to return 0. However, I consider this case a valid update task. How would I test it, so I can assign a success message?

Is update() returns -1 when SQL query failed or also 0?

Method: Zend_Db_Table_Abstract::update()

Any ideas?

Thanks

like image 483
AD. Avatar asked Dec 17 '25 18:12

AD.


1 Answers

Zend_Db can only return what the MySQL adapter can return. Which would be the number of rows updated. However it does throw an exception in the event that a query errors out. So your best bet would be to wrap your update statement in a try/catch. If it catches an exception, then display an error in your application. If it does not, then consider the query executed correctly, even if no data was updated.

like image 51
Mark Avatar answered Dec 21 '25 21:12

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!