DISTINCT不使用hasMany cakephp
我想在CakePHP2+中应用DISTINCT查询,它工作得很好,但当我用该模型绑定模型时,它不工作 这是我的密码,请核对一下DISTINCT不使用hasMany cakephp,php,cakephp,Php,Cakephp,我想在CakePHP2+中应用DISTINCT查询,它工作得很好,但当我用该模型绑定模型时,它不工作 这是我的密码,请核对一下 $this->User->bindModel( array( 'hasMany' => array( 'UserPreference' => array(
$this->User->bindModel(
array(
'hasMany' => array(
'UserPreference' => array(
'className' => 'UserPreference',
'foreignKey' => 'user_id',
'fields' => 'UserPreference.notification_status',
'conditions' => array('UserPreference.notification_status' => 1),
)
)
)
);
$data = $this->User->find('all', array('conditions' => array('app_id NOT ' => '0', 'User.status' => 1), 'fields' => array('DISTINCT User.app_id')));
pr($data); die;
就因为我曾经发生过这样的事情,我就改变了它:
$this->User->bindModel(
array(
'hasMany' => array(
'UserPreference' => array(
'className' => 'UserPreference',
'foreignKey' => 'user_id',
'fields' => 'UserPreference.notification_status',
'conditions' => array('UserPreference.notification_status = 1'),
)
)
)
);