Add Condition On Field In Remote Table To Criteria


I wonder how I can do this thing: I have a model Request with field "cdr_id". I use this field to fetch some extradata from mysql database on the other host. For this I use getters like this:

public function getDuration(){

    if ($this->cdr_id)

        return Yii::app()->asteriskdb->createCommand()->select('duration')




     else return '';


Also on my site I have Grid View, which I initialize with this ActiveDataProvider:

$dataProvider = new CActiveDataProvider('Request', array(

    'criteria' => array(

        'with' => array('categoryInfo', 'operator', 'department'),

        'condition' => "cdr_id != 'NULL'"


    'sort' => $sort,

    'pagination' => array(

        'pageSize' => Yii::app()->params['requestsPerPage']



So my question is: how can I filter data in provider using database table on another host?

Without using joins, the only option for you is filtering by php functions.

Yep, I’m thinking in similar way, but how can I filter data provider with custom function?