Csqldataprovider And Createcommand()

 $res = Yii::app()->db->createCommand()




                    ->leftJoin('SourceMessage','((real_estate.title = SourceMessage.message) or (real_estate.description = SourceMessage.message))' )

                    ->leftJoin('Message', 'SourceMessage.id = Message.id')

                    ->where('(Message.language="' . $lang . '"  And Message.translation LIKE "%' . $_POST['query'] . '%" and real_estate.activ=1)')



        $res = new  CSqlDataProvider($res,array('keyField' => 'id',


How can i solve this.

If i use ->text i also get an error

The CSqlDataProvider is support only string or CDbCommand $sql:

public void __construct(string|CDbCommand $sql, array $config=array ( ))


because you use the queryAll() the first $res will be an array not a CDbCommand - remove the queryAll() row or use CArrayDataProvider instead of CSqlDataProvider ;)

I agree with Argent

Also If you want to understand more about it see this wiki