开发者

php zend framework rows affected

I am using zend framework and I see save() function used in the code, would like to know if there is a way to ge开发者_如何学JAVAt the rows affected after this to see number of rows affected ..

I checked this documentation but din't help much. any ideas? thanks


The Zend_Db_Table_Row::save() method returns the primary key of the row, either the current primary key if you're updating an existing row, or a new primary key if you're saving a new row.

The save() method applies to one row instance, so as @Evernoob says it should only apply to one row. But it doesn't necessarily result in one row "affected" when you save. For instance, if I haven't changed any column values, and I save() a row, the rows affected is zero. Try something like this in the mysql shell and you'll see it reports zero rows affected.

UPDATE mytable SET column1 = column1 WHERE id = 1234; -- effectively a noop

The Zend_Db_Statement has a method rowCount() (mimicking the PDOStatement rowCount() method), but this information is not surfaced through the Zend_Db_Table_Row interface.

So if you need that information, you'll have to update your data using Zend_Db_Adapter::query() to create a Zend_Db_Statement object. After you execute() the statement, you can call rowCount() on it.


the save() function is applied to the instance of that object, which is associated with one row. You can therefore safely assume that calling save() on an object will only affect its one associated row.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜