php - Trying to use "not like" operator on CakePHP

270

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.

514

Answer

Solution:

Try to use array

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

People are also looking for solutions to the problem: javascript - Conflict with JQuery on Symfony 3 while submitting form

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.