title: Yii createCommand not not returning correct results
body: <p>I am trying to get a random ID from a table with a specific <code>visiblity=2</code> clause but I am having issues getting it to return the ID, it says <code>Undefined index: id</code>.</p>
  
  <pre><code>     $space = Yii::app()-&gt;db-&gt;createCommand()
           -&gt;select('id')
           -&gt;from('space')
           -&gt;where('id=rand() AND visibility=2')
           -&gt;limit(1)
           -&gt;queryAll();
           //-&gt;queryRow();
       echo $space['id'];
  </code></pre>
  
  <p>Is his not the correct way?</p>
  
  <p>I figured out another solution using the already loaded info from my original version without guest check.</p>
  
  <pre><code>    $max = Space::model()-&gt;count();
      $randId = rand(0,$max);
      $space = Space::model()-&gt;find(array('offset'=&gt;$randId));
      if ($space-&gt;attributes['visibility'] == 2) {
  </code></pre>