dongtui6347 2017-06-18 19:55
浏览 29

试图在CakePHP上使用“not like”运算符

I'm trying to use the "not like" operator in cakephp, if I use this:

$users = $this->find('all', array(
            'fields' => array(
                'User.id', 'User.first_name', 
                'User.last_name', 'User.country', 
                'User.division', 'User.department',
                'User.function'),
            'recursive' => -1, 
            'order' => array('User.first_name ASC'), 
            'conditions' => array(
                'User.active' => true,
                'User.company' => $comp,
                'User.country' => $country,
                'User.division' => $division,
                'User.department' => $dpto,
                'NOT' => array(
                    'User.function LIKE' => 'COORD%'                    
                )
            )
        ));

The code works, however, if I try to put two same fields instead of one with different values like this:

'NOT' => array(
                'User.function LIKE' => 'COORD%',
                'User.function LIKE' => 'MANAG%'
            )

It doesn't work, what am I doing wrong?

EDIT

I already fixed it that day like this:

'NOT' => array(
                'User.function LIKE' => 'COORD%','User.function LIKE "MANAG%"'
              )

I hope this is useful for someone.

  • 写回答

1条回答 默认 最新

  • dongrao9454 2017-06-19 06:11
    关注

    Try to use array

    'NOT' => array(
        'User.function LIKE' => array(
            'COORD%',
            'MANAG%'
        )
    )
    
    评论

报告相同问题?