Sub select in CDbCriteria condition

hello,

could anyone translate this sql statement into CDbCriteria ?




select approval.*, commission_form.form_id from approval, commission_form 

	where approval.refer_id = commission_form.form_id and 

  	      approval.type = "CommissionRequest" and 

	      2 = (select status from approval where type = "CommissionRequest" and refer_id = commission_form.form_id    order by 	ordering desc limit 1) group by commission_form.form_id order by commission_form.form_id desc



below is my code :




$criteria->condition = '$status = (select status from approval where type = "CommissionRequest" and refer_id = t.form_id order by ordering desc limit 1)';



i have tried several times and always got this error "Invalid parameter number: number of bound variables does not match number of tokens"

thanks

any suggestion please? is it possible to implement sub select / sub query using CDBCriteria?

thanks

I’d guess you meant to use the value of $status




$criteria->condition = $status.' = (select status from approval where type = "CommissionRequest" and refer_id = t.form_id order by ordering desc limit 1)';



/Tommy

hi tom,

still get the same error "i have tried several times and always got this error "Invalid parameter number: number of bound variables does not match number of tokens"

thanks