Answer the question
In order to leave comments, you need to log in
Yii2 - how to process and output data?
Hello! Fate sent me to deal with yii2, which I did not know before, and the farther into the forest, the more terrible it becomes. The sea, kmk, incredible inheritances cause more disgust than the desire to use this framework.
Question 1. I have goods stored in the database, the goods have some final set of properties. These are three tables:
products:
-id
-name
-user /*принадлежность товара пользователю, см. ниже*/
properties
-id
-name
productproperties:
-id
-product
-property
-value
Answer the question
In order to leave comments, you need to log in
1. Describe relays for AR models and display data in the form. It's not at all clear what the problem is. Read more here:
www.yiiframework.com/doc-2.0/guide-db-active-recor...
2. Yes, that's fine. But it's better to create a method that will search by user_id
public function getByUserId($id) {
$this->where('user_id = ' . (int) $id);
}
Products::find()->getByUserId(Yii::$app->user->id)->all();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question