S
S
slip312014-07-29 16:56:43
Yii
slip31, 2014-07-29 16:56:43

Writing to multiple tables (models) in Yii2. How to implement?

I am making an article module (with multilingualism) - according to this article habrahabr.ru/post/226931
Accordingly, I have two tables ".....
The post table (Post model) - we store meta-information that is not related to the content. That is the following fields: id, owner_id, date_create, date_update
Table post_lang(PostLang model) - content linking by language Fields: id, post_id, lang_id, name, description Accordingly, the post_id fields are id from the post table, lang_id is the id from tables lang. name and description - content in the corresponding language. ...."
How to write to two models at once when creating an article?
Those. I need to record information on creation in both Post and PostLang so that id.post = post_id.postlang.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-07-29
Protko @Fesor

You need to normalize the data. Then you can use something like this:
https://github.com/yiisoft/yii2/blob/master/docs/g...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question