我在mysql中有这样的db结构。我用的是蛋糕PHP3.5。我想在表1中添加一个与表4的连接。把它的倒数也加到表4上。
$this->belongsToMany('Table4', /*What goes here*/);
表4是什么?我能和伯朗格默尼的探险家一起去吗?谢谢!
klr1opcd1#
正如ndm在评论中所说,cake不支持您想做的事情,只是出于一个原因,这不是一个多对多的关系,请首先通过迁移创建您的数据库https://book.cakephp.org/3.0/pt/migrations.html 之后(bake migration,execute migration)您的数据库将存在,您可以运行bake for create models,然后您将意识到您可以像
$this->table1->table2->table3->table4->find()->where([conditions]);
或者其他类似的
$this->table1->find()->contain(['table2' => ['table3' => ['table4' => 'conditions' => ['RealConditions']]]])->first();
如果你不想学习所有这些,你可以走完整的道路。或者先看看https://book.cakephp.org/3.0/en/orm/associations.html#belongstomany-联想
1条答案
按热度按时间klr1opcd1#
正如ndm在评论中所说,cake不支持您想做的事情,只是出于一个原因,这不是一个多对多的关系,请首先通过迁移创建您的数据库https://book.cakephp.org/3.0/pt/migrations.html 之后(bake migration,execute migration)您的数据库将存在,您可以运行bake for create models,然后您将意识到您可以像
或者其他类似的
如果你不想学习所有这些,你可以走完整的道路。或者先看看https://book.cakephp.org/3.0/en/orm/associations.html#belongstomany-联想