title: Storing long decimal in mysql using PDO
body: <p>I am storing a decimal value in a mysql database where the column data type is decimal(12,2).</p>
  
  <p>If I input 10000 then it's fine. But if I want to store 100000 the table is not storing the value.</p>
  
  <p>My code is </p>
  
  <pre><code>$query = $this-&gt;db-&gt;insert('donation', array(
              'donation_ref'      =&gt; $unique,
              'user_id'           =&gt; $data['donorid'],
              'donation_amt'      =&gt; $data['amount'],
              'cause_id'          =&gt; $data['causes_i_want_to_support'],
              'countrytospend'    =&gt; $data['country_to_spend'],
              'donation_type'     =&gt; $data['donation_type'],
              'donation_prompt'   =&gt; $data['donate_prompt'],
              'gift_aid'          =&gt; $data['total'],
              'donation_date'     =&gt; date('Y-m-d', strtotime($data['donation_date'])),
              'giftaidyesno'      =&gt; $ga,
              'donation_method'   =&gt; $data['donation_method']
          ));
  
  public function insert($table, array $data)
      {
          ksort($data);
   $fieldNames = implode('`, `', array_keys($data));
      $fieldValues = ':' . implode(', :', array_keys($data));
  
  
          $sth = $this-&gt;prepare("INSERT INTO $table (`$fieldNames`) VALUES ($fieldValues)");
  
  
          foreach ($data as $key =&gt; $value) {
              $sth-&gt;bindValue(":$key", $value);
          }
  
          $sth-&gt;execute();
      echo print_r($sth-&gt;errorInfo());
      }
  </code></pre>
  
  <p>The debug output is </p>
  
  <pre><code>    Insert prepared
  Insert executed
  object(PDOStatement)#32 (1) { ["queryString"]=&gt; string(364) "INSERT INTO donation (`cause_id`, `countrytospend`, `donation_amt`, `donation_date`, `donation_method`, `donation_prompt`, `donation_ref`, `donation_type`, `gift_aid`, `giftaidyesno`, `user_id`) VALUES (:cause_id, :countrytospend, :donation_amt, :donation_date, :donation_method, :donation_prompt, :donation_ref, :donation_type, :gift_aid, :giftaidyesno, :user_id)" } 
  </code></pre>
  
  <p>Error handling --</p>
  
  <pre><code>public function __construct($type, $host, $databaseName, $username, $password)
      {
          parent::__construct($type.':host='.$host.';dbname='.$databaseName.';charset=utf8', $username, $password);
          $this-&gt;exec('SET CHARACTER SET utf8');
  
          if ($this-&gt;debug) {
              $this-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
          }
      }
  
      /**
       * Enable/disable debug for database queries.
       * @param $debug boolean TRUE to enable debug, FALSE otherwise.
       */
      public function debug($debug)
      {
          $this-&gt;debug = $debug;
      }
  </code></pre>
  
  <p>There is no error from mysql end as I can insert the same value manually in the table. But when I am trying to store it via PDO then there is no error and it is not storing the row as well.</p>
  
  <p>Any help is highly appreciated.</p>