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?
Asked
Active
Viewed 2,702 times
7
-
Was the record retrieved as part of a query that used a join or did the select disable the setIntegrityCheck flag? – drew010 Apr 27 '12 at 17:50
-
possibly...why do you ask? Am I not allowed to join other data on the model if I am going to save it later? – Andrew Apr 27 '12 at 19:17
-
2If either were the case, then the row object returned will be marked as read only because the integrity check is turned off and it doesn't guarantee that the object is compatible with the table object anymore so you can't directly update it, you'd have to create a new object of your row class and copy the data to it. – drew010 Apr 27 '12 at 21:20
-
That makes sense. You should move this into an answer so I can accept it. – Andrew Apr 28 '12 at 00:35
1 Answers
9
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.

drew010
- 68,777
- 11
- 134
- 162
-
possible typo - I believe `setIntegrityCheck(TRUE)` is what you meant as we normally set it to `FALSE` to allow joins. Although I could have the context backwards. – RockyFord Apr 28 '12 at 06:45
-
It's correct, if you disable the integrity check `setIntegrityCheck(false)` then the row is marked read only. If the integrity check is on, and it passes, then the row is mutable. – drew010 Apr 28 '12 at 16:53
-