Reputation: 2032
Why does this returns empty
{}
?
$model= \common\models\rps\RpsChecklist::findOne($id);
return json_encode($model);
I tried return json_encode($model->id);
it returns just the exact ID.
Upvotes: 0
Views: 569
Reputation: 463
findOne()
will return an active record object. In your case is RpsChecklist
model.
If you want to use json_encode()
function, object must be array.
So my solution is:
$model= \common\models\rps\RpsChecklist::find()->where(['id' => $id])->asArray()->one();
return json_encode($model);
Goodluck and have fun.
Upvotes: 4