views:

29

answers:

1

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

+2  A: 

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.

Mark
+1 this is the way to go
robertbasic
Thanks guys... makes sense, will do so
AD