title: convert tinyint into boolean for later use with php json_encode
body: <p>i have a table field that's type is <code>tinyint</code>. so the values in mysql can be stored as <code>1</code> for <code>true</code> and <code>0</code> for <code>false</code>.</p>
  
  <p>i used php's mysqli module to fetch the data.
  e.g.</p>
  
  <pre><code>$result = $mysqli-&gt;query("SELECT * FROM table_x_y");
  $row = $result-&gt;fetch_assoc()
  </code></pre>
  
  <p>now i get a data row of the table. but the fields with the type <code>tinyint</code> are integers not boolean. 
  the problem come with php's <code>json_encode</code>. i want to create a JSON object. But the boolean fields are still integer (in <code>$row</code>) and the encode function treated them as integer not as a boolean.</p>
  
  <p>the result of the json object looks like</p>
  
  <pre><code>[
    {
      "foo": 1,
      "bar": 2
    },
    {
      "foo": 0,
      "bar": 1
    }
  ]
  </code></pre>
  
  <p>but i should look like </p>
  
  <pre><code>[
    {
      "foo": true,
      "bar": 2
    },
    {
      "foo": false,
      "bar": 1
    }
  ]
  </code></pre>
  
  <p><strong>Info</strong>
  <code>foo</code> datatype is <code>tinyint</code>.
  <code>bar</code> datatype is <code>int</code></p>