Anyone have a createCommand example? So I am using a plugin to import data and it isn't assigning the values (asset is inside of Matrix) so I am going to modify the plugin and add code to lookup values that I need to assign to MatrixBlockModel and then re-save the item. 

I looked up how to create a command and based on that I wrote 3 lines of code but I have no idea on how to iterate through the results. Here is the sample code:

$query=craft()-&gt;db-&gt;createCommand()
  -&gt;select('id, folderId, filename, kind')
  -&gt;from('{{ assetfiles }}')
  -&gt;where('filename= :fileName', array(':fileName' =&gt; 'somefilename'));


How do I iterate through the results and how can I access info from the query?
I'd suggest reading through the Yii QueryBuilder docs, which is what the code you've written is using.

-&gt;from('{{ assetfiles }}')


should be:

-&gt;from('assetfiles')


And if you want multiple rows returns as a a result, you need to add a:

-&gt;queryAll();


to the end of the statement.

From there, you can do a foreach loop to access the results of your query:

foreach ($query as $row)
{
    $id = $result['id'];
}