How to compare an attribute with a function in CDbCriteria ?

I have a function in my model

public function getLastContact()

{


	return !empty($this->contacts)?$this->contacts[0]->contact_time:'';


}

Is there a way to search the above function with the attribute from gridview search?

Something similar to below

public function search()

{


	$criteria=new CDbCriteria;


	


	$criteria->compare('t.getLastContact()',$this->lastContactDate);


	


	$criteria->compare('date',$this->date,true);


	$criteria->compare('interests',$this->interests,true);


	return new CActiveDataProvider($this, array(


		'criteria'=>$criteria,


	));


}

Unfortunately this won’t work.

As you see in the reference, the first parameter for CDbCriteria::compare() is

CDbCriteria::compare()

Usually it is a name of a column in a table. You can not use a PHP method here.

But you can use a valid SQL expression instead of a column name here. So what you have to do is write some SQL expression that is equivalent to the PHP method "getLastContact()".

Thank you for your support