Answer the question
In order to leave comments, you need to log in
How to return an array from activeRecord to a view?
It turns out that when I return a value from ActiveRecord in the form of json_encode I get an empty value, if so, as I did, then it's normal.
public function actionPagination($id, $offset)
{
$offset = $offset * 6;
$arr = [];
$comment = Comment::find()->where(['id_zakaz' => $id])->orderBy('id DESC')->offset($offset)->limit(6)->all();
foreach ($comment as $key => $com){
$arr[$key]['comment'] = $com->comment;
$arr[$key]['date'] = $com->date;
$arr[$key]['user_id'] = $com->id_user;
}
return json_encode($arr, JSON_UNESCAPED_UNICODE);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question