Field_Value::model()->with('field')->deleteAllByAttributes(array( 'field.profile_id' => $this->profile_id, ));
Since the with() method in the chain returns a CActiveFinder instead of CActiveRecord, this obviously won't work. Assuming I don't want to use direct SQL, what would be the best way to handle this situation? All I can think of is SELECTing all Field_Value records, put their IDs in an array and use that array in a subsequent DELETE query. I hope there is a better way.