开发者

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 wou开发者_开发技巧ld 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜