D
D
des1roer2015-05-19 10:18:36
Yii
des1roer, 2015-05-19 10:18:36

Yii 1.x create field in model from another table?

Suppose I have a many-to-many relationship
amKNT.png
Can I create a field in the main model under elem.name ?
yii 1.1.16

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronii, 2015-05-19
@Ronii

$elem = new Elem();
$elem->id = 'kuku';
$elem->save();

$link = new MainHasElem();
$link->id_main = $this->id;
$link->id_elem = $elem->id;
$link->save();

More through relationships and the link method

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question