common\models\PostComment::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('comment' . $id))) {
            $model = static::find()->where(['id' => $id])->andWhere($condition)->one();
        }
        if ($model !== null) {
            Yii::$app->cache->set('comment' . $id, $model, 0);
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }