在 CakePHP 2 的二级关联上应用 where 条件。5.x
Apply where condition on 2nd level association in CakePHP 2.5.x
我想在 cakephp 中为我的二级关联添加一个 where 子句。以我的理解,这应该可行,但它给了我一个错误
错误:[PDOException] SQLSTATE[42S22]:找不到列:1054 'where clause' 中的未知列 'User.email_address'。
$options = array(
'contain' => array(
'People',
'People' => array('User')
),
'conditions'=> array(
'User.email_address' => 'sample@mail.com'
),
'recursive' =>1,
);
$query = $this->Organization->find('all', $options);
$options = array(
'contain' => array(
'People' => array(
'User' => array(
'conditions'=> array(
'User.email_address' => 'sample@mail.com'
),
),
),
),
//'recursive' =>1,
);
$query = $this->Organization->find('all', $options);
阅读更多:
我想在 cakephp 中为我的二级关联添加一个 where 子句。以我的理解,这应该可行,但它给了我一个错误
错误:[PDOException] SQLSTATE[42S22]:找不到列:1054 'where clause' 中的未知列 'User.email_address'。
$options = array(
'contain' => array(
'People',
'People' => array('User')
),
'conditions'=> array(
'User.email_address' => 'sample@mail.com'
),
'recursive' =>1,
);
$query = $this->Organization->find('all', $options);
$options = array(
'contain' => array(
'People' => array(
'User' => array(
'conditions'=> array(
'User.email_address' => 'sample@mail.com'
),
),
),
),
//'recursive' =>1,
);
$query = $this->Organization->find('all', $options);
阅读更多: