CDbCriteria represents a query criteria, such as conditions, ordering by, limit/offset. It  helps us to simplified our database query.

For instance, these query might be “WHERE, ORDER, SELECT, GROUP BY..” and after do this query to database and the results will be loaded to CActiveDataProvider and send its to view.
See my example code
$criteria = new CDbCriteria();
$criteria->with=array('detail');
$criteria->compare('type_dorm_', 0);

$dataList = new CActiveDataProvider('Dorm',array(
    'criteria'=>$criteria,
    'pagination' => array(
      'pageSize' => 5,
    )
  ));

$this->render('index', array('dataList'=>$dataList));

See, it’s easy. I use CDbCriteria load the detail where type_dorm = 0 and then get all records load it to CActiveDataProvider, after that send these records to view for display.