CakePhp 2.0中“子模型”中的Where子句

问题描述 投票:1回答:1

如何在此代码中插入关于模型“为什么”的where子句。

我必须按表格的特定class_id过滤(在蛋糕模型'为什么')。

你应该知道Pilot有很多为什么。

感谢帮助

$allplants = $this->Plant->find('all',[
    'contain'=>array('Pilot'=>array(
    'Lever',
    'Area',
    'Why',
    'conditions'=> array('published' => 1, $conditions,"OR"=>$or_conditions))),
    'conditions' => $plantConditions]
);
php mysql cakephp-2.0
1个回答
0
投票

尝试一次,我实现的类似代码在cakephp3中工作。

$allplants= $this->Plant->find('all')->contain(['Pilot', 'Lever', 'Area'])
            ->innerJoinWith('Pilot.Why', function ($q) {
                return $q->where($WhyConditions);
            })
            ->conditions($plantConditions);
© www.soinside.com 2019 - 2024. All rights reserved.