AR and 'not in' statement


I have:


How can I get all these models, but where it’s id not in another models list

Can it be AR request, or need to use Command Builder?

Please clarify your problem:

  • do you mean you want NOT IN statement,

  • or do you mean you want only models that have related models?

something like

select * from a where not in (select someid from <img src='' class='bbc_emoticon' alt='B)' /> 

with AR

As it is very complicated, I firmly believe you have to handcode this query with command builder.

or it can be AR with left join and id not null in b table :)

Yes, but that won’t be the embedded sql you asked. :) Still, it is working. And nothing else matters.

could you give a code example how this could be done with AR?


i think it must be something like this, but in my case it does not work any ideas?

BsoType::model()->with(array('bsoRequest'=>array('condition'=>'??.id is null')))->findAll();

BsoType::model()->with(array('bsoRequest'=>array('condition'=>'??.id is null')))->together()->findAll();