I’ve been thinking about some of the errors I’m fighting. One of the most obscure from above has 2 components. The _to_array method, used to get the insert and update array, doesn’t check to see if a field is not set. Because it doesn’t, there isn’t a way to insert a row into the database that has a default value.
For example, I have a NOT NULL field with a default, and when I create a new item, I don’t want to have to set that field. (I know I can work around this by setting all the defaults in my constructor, but I don’t think I want to do this, yet.)
The second part of this is that the _clear method sets all the fields to NULL. I think it makes more sense to unset the fields completely. This truly clears out the data. Any thoughts?
I think there is a “bug” in your insert/update checking, but it’s obscure: an ‘id’ of 0 (zero) will always be inserted, even if it is supposed to be updated. Probably best to leave this one, but I thought I’d point it out for the documentation.
Last, on the issues of table names and pluralities: This has caused me no end to frustration. Apparently, somewhere in the code, one of the functions is still trying to ‘convert’ the model name, instead of using the provided $table and $model. This is an issue, because the table is named statuses (yes, it’s correct), and the model is Status. I keep getting errors where the joining table is labeled status, and the model gets renamed statu!