CActiveRecord without DB table

I need a custom class that is similar to the CActiveRecord but without the related database table.

The reason is that I need to set the attributes of the class as follows.


I have compared two classes of CActiveRecord and its parent CModel.

CModel: does not have setters and getters for attributes.

CActiveRecord: must have a database table.

Obviously, I have tried to extend CModel, borrowing some functionalities from CActiveRecord, I failed to do for I was not able to get meta data of the members (properties).

Does anyone can help me? Thanks in advance :)

Yes, CModel has the same functionality, see:

See also and

CForm is working at the situation without table.

Thanks mentel and Boy.Lee.

The reason I cannot massively assign the properties was a rule which I have not defined in the model.

I made my model extending CFormModel (because this is described as ActiveRecord without database) and made a rule that the properties are ‘safe’, I was succeded to assign those properties massively. :D

Thanks again,

BTW, extending from CModel is not working because we have to define attributeNames() (with this method, it is working), extending from CForm is not working because it may requires the class config file for the constructor. Consequently CFormModel is the best choice, I suppose.

Yes, it is.

If our posts helped you, please vote! :)


Did it. Thank you! :D