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类的实例。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号