Condition in ActiveRecord


I need to use "not in" condition, I tried it:

$array = [1,4,6];

$free_agents = RiskAgents::findAll(['status' => '1','not in','attribute',$array]);

But don’t worked and did not do anything, and don’t show error.

How can i use this condition?

$array = [1,4,6];

$free_agents = RiskAgents::findAll([ ['not in', 'status',$array] ] );

Hello Fabrizio

Don’t work, I put it:

$array = [1,4,6];

$free_agents = RiskAgents::findAll( ['status' => '1','not in', 'id',$array]  );

I Tried this too:

$free_agents = RiskAgents::findAll( ['status' => '1'],['not in', 'id',$array]  );

don’t return anything. I need show data that status = 1 and id don’t have in my array.

I did it:

$free_agents = RiskAgents::find()->where(['not in', 'id',$array])->all();

And worked ok, but I need include a condition status=1, when I put this condition:

$free_agents = RiskAgents::find()->where(['not in', 'id',$array, 'status'=>'1'])->all();

The app show datas but ignore the condtion status=1, using only ‘not in’. Can i put more than a condition in this case?

$free_agents = RiskAgents::find()->andWhere(['not in', 'id',$array])->andWhere(['status' => 1 ])->all();

Perfect. this worked very good.