Answer the question
In order to leave comments, you need to log in
Is it possible to do a collection search in Yii2?
Good afternoon, could you tell me if it is possible to make a selection, for example, of an article with status two.
article
-----------------------
id
title
status
description
And then search this collection ($articles ) , for example in titles (title) - %article %? $articles = Article::findAll(['status' => 2]);
Answer the question
In order to leave comments, you need to log in
And what's the problem with doing a search right away?
$articles = Article::findAll([
'status' => 2.
'title' => '...'
]);
$query = 'поисковый запрос';
$articles = Article::find()
->andWhere(['status' => 2])
->andWhere(['like','title',$query])
->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question