Cakephp 4 -如何合并关联表?

zyfwsgd6  于 2022-11-11  发布在  PHP
关注(0)|答案(1)|浏览(151)

是否可以将关联表合并为Union?将其与条件一起显示

$this->paginate = [
  'contain' => ['Users', 'Posts', 'Comment', 'likes'],
];
$tweets = $this->paginate($this->lists);

类似于查询生成器,因此我还可以为帖子和评论添加条件

$table1 = $this->tableName
  ->find()
  ->join()
  ->where()

$table2 = $this->tableName
  ->find()
  ->join()
  ->where()

$Union->Union($table1)
nkkqxpd9

nkkqxpd91#

使用联合可以执行如下操作

$table1 = $this->tableName
  ->find()
  ->join()
  ->where()

$table2 = $this->tableName
  ->find()
  ->join()
  ->where()

$table2->union($table1);

相关问题