Post::model PHP Method

model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : Post
$className string
return Post the static model class
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

Usage Example

Example #1
2
 public function run()
 {
     $tags = Tag::model()->findAll();
     if ($tags) {
         foreach ($tags as $tag) {
             $post = Post::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $image = Image::model()->findAll("FIND_IN_SET(:tag, tags)", array(':tag' => $tag->tag_name));
             $soft = Soft::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             $video = Video::model()->findAll("FIND_IN_SET(:tag, seo_keywords)", array(':tag' => $tag->tag_name));
             if (!$post && !$image && !$soft && !$video) {
                 $tag->delete();
             } else {
                 $tag->data_count = count($post) + count($image) + count($soft);
                 $tag->save();
             }
         }
     }
     $tagdatas = TagData::model()->findAll();
     if ($tagdatas) {
         foreach ($tagdatas as $value) {
             $modelType = ModelType::model()->findByPk($value->type);
             $model = $modelType->model;
             $data = $model::model()->findByPk($value->content_id);
             if (!$data) {
                 $value->delete();
             }
         }
     }
     $this->controller->message('success', Yii::t('admin', 'Reset Tags Success'), $this->controller->createUrl('index'));
 }
All Usage Examples Of Post::model