frontend\modules\topic\models\Topic::findModel PHP Method

findModel() public static method

通过ID获取指定话题
public static findModel ( $id, string $condition = '' ) : array | null | ActiveRecord | static
$id
$condition string
return array | null | yii\db\ActiveRecord | static
    public static function findModel($id, $condition = '')
    {
        //        if (!($model = Yii::$app->cache->get('topic' . $id))) {
        $model = static::find()->where($condition)->andWhere(['id' => $id, 'type' => self::TYPE])->one();
        //        }
        if ($model) {
            //            Yii::$app->cache->set('topic' . $id, $model, 0);
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }