I am a newbie to ar orm pattern. ActiveRecord is convenient for query relations and create/update on single record, but seems lack of supprot for create/update on relation. I want to do some automatic operations on the relations in the model ( now I put the logic in controller ), but I don’t know how to determine whether an ar object is ‘dirty’, that is, a new object or a loaded object which has been assigned any attribute and need to be saved. Would somebody show me how?
This only checks wether loaded model is a new or existing record. Example of this check is in every _form.php view file generated by gii tool, where it is being used to determine if user should see Add (for new record) or Update (for existing ones) label on submit button.
This AFAIK does not check whether loaded existing model (record) should be saved because it was changed somehow.