Is there any way to convert ActiveRecord to an array in Yii2? I do know we can do that for ActiveQuery, for example User::find()->asArray(
ActiveRecord
ActiveQuery
User::find()->asArray(
Try this!
$model = Post::find($id)->limit(10)->asArray()->all(); $model = Post::find($id)->select('id,name as full')->asArray()->one(); $model = Post::find($id)->select('id,name as full')->asArray()->all(); $model = Post::find()->where(['slug'=>$slug])->asArray()->one();