title: PHP PDO Driver returns Decimal(10,2) values as a string
body: <p>Given the following table in the database:</p>
  <pre><code>create table products
  (
      id    int auto_increment,
      item  char(20)       null,
      price decimal(10, 2) null,
      constraint table_name_pk
          primary key (id)
  );
  
  create unique index table_name_id_uindex
      on table_name (id);
  
  </code></pre>
  <p>When you run this code:</p>
  <pre><code>$sql = &quot;SELECT price FROM products WHERE id = :item_id&quot;
  $values = [ 'item_id' =&gt; 100 ];
  $stmt = $dbh-&gt;prepare($sql);
  $stmt-&gt;execute($values);
  $obj = $stmt-&gt;fetch(PDO::FETCH_OBJ);
  </code></pre>
  <p>The value of <code>$obj-&gt;price</code> will be a string instead of a float.</p>
  <p>Is there any way to tell the PDO driver to cast this as a float?</p>
  <p>Note:
  I understand that using <code>PDO::FETCH_CLASS</code> with a pre-defined object will do what I am asking. That's not what I want here. Making an entire class for each table that has dollar values in it is cumbersome, and requires a lot of work when the database changes (updating integration tests, etc...).</p>
  <p>I also understand that this may be the <em>desired</em> behavior because float is a power of 2, and the MariaDB / MySQL data types are not. So, string may be the natural and best choice.</p>