Answer the question
In order to leave comments, you need to log in
Is it possible to create one model for two tables in Yii?
When adding an article to the database, you have to write it to two tables: the main one - articles and the additional one - tags. Is it possible in Yii to create a model based on two tables and it is convenient to work with this model through the controller?
Answer the question
In order to leave comments, you need to log in
the answer is no, but here is what you need:
yiiframework.ru/doc/cookbook/ru/model.save.related.data
habrahabr.ru/post/118910
habrahabr.ru/post/200478
Generally speaking, it is possible, although perverted:
public function tableName() {
$tableNum = (isset($_REQUEST['bookindex'])) ? (int)$_REQUEST['bookindex'] : 1;
return 'gbook'.$tableNum.'_messages';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question