Answer the question
In order to leave comments, you need to log in
Take data from two tables in Yii2?
Good time everyone.
A little confused in learning Yii2 need help!!
There are two sql tables - 1) contacts, 2) phone_numbers
contacts contains id, name, surname fields and phone_numbers table contains phone_number and contact_id fields.
The bottom line is to take all fields from the contacts table with fields attached to them on request:
SELECT
contacts.name, contacts.surname, contacts.patronymic, phone_numbers.phone_number
FROM contacts
INNER JOIN phone_numbers
ON
`contacts`.`id` = `phone_numbers`.contact_id
I can’t understand how to make a request, I can’t really find it anywhere. There is a similar topic on the forum, but knowledgeable people communicate there, I can’t understand anything from their intricate entries!
Can you explain to a young man?
Thank you!
Answer the question
In order to leave comments, you need to log in
Do you really need Windows to "watch sites and download files"?
In Linux, your problem is solved simply and naturally.
to solve this problem, use ActiveRecord and its data linking mechanisms
or if you want to create SQL queries yourself - the query builder built into Yii2
is there for you and your JOIN and everything else will be easy to use out of the box, just learn
the framework object model first, otherwise, it seems to me, you are swimming. what is a model, controller and general MVC base
is also useful to delve into the finished code, which has already been mentioned here more than once, this will help you understand how to do it better and teach you to understand someone else's code and eliminate a lot of problems. examples: store on Yii2 - DotPlant. forward to their github repository, from the first Yii they made a good Yupe in their time, just as useful, just read carefully so as not to learn the old code, because in the new one (it’s better to write your code directly in Yii2, in my opinion) then you will make mistakes
and do not be lazy to ask Google, there is a wagon and a cart on the topic
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question