yii中有这样一段代码,$post=post::model()->findbyattributes($attributes,$condition,$params);
post::model()->find()->attributes。
这里的model()改如何理解啊
回复讨论(解决方案) model覆盖了父类方法,实例化这个类的对象。
你的例子,也就是说model()实例了post这个类的实例
findbyattributes这个方法也在父类里。
//这个是ar类里的方法。public static function model($classname=__class__){ if(isset(self::$_models[$classname])) return self::$_models[$classname]; else { $model=self::$_models[$classname]=new $classname(null); $model->_md=new cactiverecordmetadata($model); $model->attachbehaviors($model->behaviors()); return $model; }}
post::model() 返回一个指定的对象
model方法返回post类的实例。