A
A
agent11562017-01-04 12:48:57
Yii
agent1156, 2017-01-04 12:48:57

Database Relationships in Yii2?

Hello.
A question. When I make links in phpmyadmin why do I need to make links in yii2 models. ? I have to enter

public function getOrders()
    {
        return $this->hasMany(Order::className(), ['customer_id' => 'id']);
    }

Maybe in phpmyadmin you don’t need to make connections at all, but immediately register them in models?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-01-04
@webinar

Links in yii2 and in the database live a separate life. So - YES, you can not specify in the database. This will not affect the work of links in yii.
However, it is worth remembering that links in yii and in the database work differently - they do not delete related data, etc. It's just a link to get related data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question