Zend Framework: This row has been marked read-only

2019-04-29 01:17发布

问题:

This is the first time I've come across this issue. When saving one of my models I get the error message: "This row has been marked read-only". Not sure why I'm getting this error and how to solve it. The stack trace didn't help me. How can I resolve this issue so I can save the record?

回答1:

Having a row marked as read only can be the result from any of the following operations:

  • The Zend_Db_Select query joined with another table
  • setIntegrityCheck(false) was set on the select object
  • One or more columns is the result of an evaluated expression

If any of the above conditions are true, then the resulting row object will be marked as read only, because Zend_Db cannot guarantee that all columns in the result reference the original parent table of the select object. Therefore any attempt to call update(), save(), or delete(), on the row object will fail.

Some of this information is spread throughout the Zend_Db_Table reference, where if you search for integrity you can see a number of instances where rows will be marked read only.