K
K
Kurper2019-10-29 11:54:10
Yii
Kurper, 2019-10-29 11:54:10

How to write one query for two tables?

Hello. There are two tables, almost the same, for example:
table1
id, id_car, capacity, color...
table2
id, id_bike, capacity, color...
and there is a page with different search queries for table1, the second one needs the same queries, but I would not like to write identical queries for two tables. Is it possible to somehow make a table selection in a query, or write queries in the main controller, and from these two inherit from the main controller, but only change the name of the table?
Can eat an opportunity to change names of tables in model? Has anyone come across this problem or can point me in the right direction?
Thanks in advance!:)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gomonov, 2019-10-29
@Kurper

https://www.yiiframework.com/doc/guide/2.0/en/db-q...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question