E
E
EVOSandru62014-11-25 04:20:53
Yii
EVOSandru6, 2014-11-25 04:20:53

How to embed a where condition in Yii query - “not equal to”?

I want to get fraternal products with one parent category.

return Product::model()->findAllByAttributes(array('CODE_PAR' => $code_par));

Here you need to insert the condition -WHERE CODE != 'x'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Frank, 2014-11-25
@Akellacom

return Product::model()->findAllByAttributes('CODE_PAR != :code_par', array(':code_par' => $code_par));

Try it like this, but I'm not sure what will happen with your method.
Is it yii 1 ?
upd
Person::model()->findByAttributes(
    array('first_name'=>$firstName,'last_name'=>$lastName),
    array(
        'condition'=>'status != :status', 
        'params'=>array(':status'=>1)
    )
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question