Return Query Builder Sql To Activerecord Model

Hello,

Anyone know how to return a ActiveRecord Object with a query builder sql?!




public static function get(){

   // 1.AR

   $result = Cms::model()->with('cmsFields')->findAll();

	

   // 2. Query builder 

   pages = Yii::app()->db->createCommand()

	    ->select('c.*, cf.*')

            ->from('cms c')

            ->join('cms_fields cf', 'c.id = cf.id_cms')

            ->queryAll();

        


    print_r($result);die;

    return $result;

} 

How to return query 2 like query 1? It’s way for that?

Thanks

You can use




CActiveRecord::populateRecord()



to do that. It is basically what CActiveRecord does anyway.

Hello Dave,

Thanks… In that away i can use Query Builder, which i like very much, and my other partner, uses activeRecord :)

I put this technic on test and see it performance.

Thanks :)