title: yii2 ActiveRecord findBySql - Response content must not be an array Error
body: <p>New to Yii2 nuances.</p>
  
  <p>Just trying to get a return from a ActiveRecord query. I realize there is probably a much easier way to do this using Yii2 conventions</p>
  
  <pre><code>public function actionGet_permissions() {
  
      $sql = 'select * from auth_item where owner_user_id IS NULL';
      return Auth_Item::findBySql($sql)-&gt;all();
  }
  </code></pre>
  
  <blockquote>
    <ul>
    <li>Errors "Response content must not be an array."</li>
    </ul>
  </blockquote>
  
  <p>I think its pretty obvious the simple set of records I'm trying to return with this function. Any help is much appreciated, and let me know if any other information will help.</p>
  
  <p>Why would findBySql not be allowed to return an array? I know I'm missing something simple here.</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit 1:</strong></p>
  
  <pre><code>Auth_Item::find()-&gt;where(['owner_user_id' =&gt; null])-&gt;all();
  </code></pre>
  
  <p>Returns the same error. And again, this seems like such a simple query.</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>Stack Trace:</p>
  
  <pre><code>Invalid Parameter – yii\base\InvalidParamException
  Response content must not be an array.
  •   1. in C:\xampp\htdocs\clienti\vendor\yiisoft\yii2\web\Response.php at line 944 
              throw new InvalidConfigException("The '{$this-&gt;format}' response formatter is invalid. It must implement the ResponseFormatterInterface.");
          }
      } elseif ($this-&gt;format === self::FORMAT_RAW) {
          $this-&gt;content = $this-&gt;data;
      } else {
          throw new InvalidConfigException("Unsupported response format: {$this-&gt;format}");
      }
  
      if (is_array($this-&gt;content)) {
          throw new InvalidParamException("Response content must not be an array.");
      } elseif (is_object($this-&gt;content)) {
          if (method_exists($this-&gt;content, '__toString')) {
              $this-&gt;content = $this-&gt;content-&gt;__toString();
          } else {
              throw new InvalidParamException("Response content must be a string or an object implementing __toString().");
          }
      }
  }
  }
  •   2. in C:\xampp\htdocs\cli\vendor\yiisoft\yii2\web\Response.php – yii\web\Response::prepare() at line 312 
  •   3. in C:\xampp\htdocs\cli\vendor\yiisoft\yii2\base\Application.php – yii\web\Response::send() at line 381 
  •   4. in C:\xampp\htdocs\cli\frontend\web\index.php – yii\base\Application::run() at line 18 
  </code></pre>
  
  <p><strong>Edit 3:</strong></p>
  
  <p>Thanks for the help guys. Json encoding the result fixed the issue.</p>
  
  <pre><code>public function actionGet_permissions() {
      $result = Auth_Item::find()-&gt;where(['owner_user_id' =&gt; NULL])-&gt;all();
      return Json::encode($result);
  }
  </code></pre>