Answer the question
In order to leave comments, you need to log in
How to search across multiple tables in a database in Yii2?
Hello.
--
I wanted to clarify how it would be more correct and safer, with joins or what other DAO queries in Yii2 to search for words or sentences in several tables?
I'm going to use Html::beginForm to not be bound to a specific action, but to pull a request from the database if a request has been made.
That is, there will be some code:
<?= Html::input('text', 'search', $search->name, ['class' => $class]) ?>
...->where(['like', 'search', $search->name])->all();
Answer the question
In order to leave comments, you need to log in
Think first about how you plan to display the results. If these are three tables, then there are different entities and making one list is not correct. Most likely these are three blocks with results, then these are 3 queries to the database and three separate arrays of objects.
I don't see the logic here, please explain.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question