Hi all......
I have two tables jobStatus and notifiactionRules, structures of tables are:
JobStatus:
id : PK
name
notifiactionRules
id : PK
status_id : FK
i want to write a condition in findAll, such that i have to get the names of all job status that are NOT IN notifiactionRules.
I tried this:
$jobstatuslist = CHtml::listData(JobStatus::model()
->findAll(array(
'condition'=>'id!=:status_id',
'params'=>array(':status_id'=>NotificationRules::model()->findAll(),'id', 'job_status_id'))
));
but i am getting error - Undefined offset: 2
can anyone pls help.......
Page 1 of 1
Findall In Relational Tables With != Condition
#2
Posted 20 December 2012 - 04:29 AM
Hi "reader"
check something like that
YourAR1::model()->findAll(array(
'condition' => YourAR2::model()->exists( 't1.id = t2.status_id')->findAll()
))
check something like that
YourAR1::model()->findAll(array(
'condition' => YourAR2::model()->exists( 't1.id = t2.status_id')->findAll()
))
#3
Posted 20 December 2012 - 04:57 AM
Hi,
you can also use SQL in findall, for instance in postgresql it would be something like
you can also use SQL in findall, for instance in postgresql it would be something like
...::model()->findAll(array('condition'=> "not exists (select 'a' from notifiactionRules where notifiactionRules.status_id = JobStatus.id)"));
#4
Posted 20 December 2012 - 05:08 AM
Hi ragua,
Thanks alot....... it works perfect...... thanks again......
Thanks alot....... it works perfect...... thanks again......
Share this topic:
Page 1 of 1

Help















