您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

model()如何理解

2024/2/26 8:30:12发布20次查看
model()怎么理解?
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类的实例。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product