title: Yii2 Active Record JSON response, type casting issue
body: <p>I am facing weird issue in Yii2 I have a query which has one join with agent table and a (one to many) relation of jobs with task it works fine but issue is it returns everything in string. Below is the query:</p>
  
  <pre><code> $query = self::find()
          -&gt;select("job.*, agent.first_name,agent.last_name")
          -&gt;leftJoin('agent', 'job.agent_id = agent.id')
          -&gt;with('tasks')
          -&gt;asArray()
          -&gt;all();
  </code></pre>
  
  <p>and the JSON encoded result:</p>
  
  <pre><code>{
    "success": true,
    "data": [
    {
    "id": "10",
    "customer_id": "1",
    "job_type": "normal",
    "created": "2016-06-22 10:19:25",
    "first_name": "Shayan",
    "last_name": "",
    "tasks": [
      {
        "id": "10",
        "job_id": "10",
        "title": "bring food",
        "instruction": null,
        "created": "2016-06-22 10:19:25",
  
      },
      {
        "id": "10",
        "job_id": "10",
        "title": "bring pizza",
        "instruction": null,
        "created": "2016-06-22 10:19:25",
  
      },
    ]
  }
  </code></pre>
  
  <p>if you notice the fields like id, customer_id and job_id these all are integer but it return as string. But if I remove ->asArray() from above query it return valid type casting but issue is it skips relational and leftJoin agent table fields, it only returns job table fields here is the response after removing ->asArray() from above query.</p>
  
  <pre><code>{
  "success": true,
  "data": [
  
   {
    "id": 10,
    "customer_id": 1,
    "name": null,
    "job_type": "normal",
    "created": "2016-06-22 10:19:25",
  },
  </code></pre>
  
  <p>If you notice in above response it does not have agent tables first_name, last_name and relational data tasks completely skipped but id and customer_id is in integer.</p>
  
  <p>Does anyone faced same issue? your help would be highly appreciated. 
  Thanks in advance.</p>