Answer the question
In order to leave comments, you need to log in
How to query a MySQL (Yii) database?
I don’t understand something
We have 2 tables
Content (with fields `id` and `pagetitle` and `template`) and Values (`contentid` and `value`)
contendid = id
We need to make a list `pagetitle`, `values1`, `values2` from two tables. After all it is possible to make one request.
Those. you need to do:
"Select all `pagetitle` where `template`=4 and by the same id select from Values all values that have contentid = id.content"
Accordingly, what to write in relations
(Content) return $this->hasMany( 'Values', ['id' => 'contentid'])
and (Values) return $this->hasOne('Content', ['contentid' => 'id']) , and in the query itself?
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