将数据添加到另一个数据透视表(多对多)

时间:2019-06-21 10:05:02

标签: php foreach many-to-many pivot-table

我尝试在我的php代码中设置2 many_many,但是我需要将其中一个数据透视表的行添加到另一个 我为它们中的每一个尝试这些代码,以制作我的many_many表:

foreach ($this->Tags() as $tag) {
            /**
             * @var BlogTag $tag
            */
            $tag->BlogID = $this->ParentID;
            $tag->write();
        }
foreach ($this->Directors() as $director) {
            /**
             * @var BlogTag $director
            */
            $director->BlogID = $this->ParentID;
            $director->write();
        }

但是我需要一个函数或foreach循环才能在我的Tags_BlogPost表中写入Directors_BlogPost行

0 个答案:

没有答案