Difference between new Model() and Model::model()

Suppose that i have a model class Model, so what is the difference between:

$x = new Model();


$x = Model::model()

Thank you.

Welcome to the forum, Kurniawan,

The former returns an instance of the model.

The latter returns the static model of the class.


The static model returned by model() contains the db schema meta data regarding the class.

So we need to call model() to get the static model when we call the functions like find() and findAll().

Hi another quetion almost the same thing.

The difference between

$Model = new ModelClass();


$model = new ModelClass;

No difference at all.

In theory, you can call find and findAll on any model, but is not correct.

there is the method CActiveRecord::model in order to have the possiblity of call method, php does not allow something like:

new ModelClass()->findAll();

thanks to clarify that.