title: PDO update table with existing value?
body: <p>I built PHP 2 year ago and now i want to change all about database to PDO,i have some problem with update table. I use this function to update table.</p>
  
  <pre><code>public function update($tabel, $fild = null ,$where = null)
      {
           $update = 'UPDATE '.$tabel.' SET ';
           $set=null; $value=null;
           foreach($fild as $key =&gt; $values)
           {
               $set .= ', '.$key. ' = :'.$key;
               $value .= ', ":'.$key.'":"'.$values.'"';
           }
           $update .= substr(trim($set),1);
           $json = '{'.substr($value,1).'}';
           $param = json_decode($json,true);
  
           if($where != null)
           {
              $update .= ' WHERE '.$where;
           }
  
           $query = parent::prepare($update);
           $query-&gt;execute($param);
           $rowcount = $query-&gt;rowCount();
           return $rowcount;
      }
  </code></pre>
  
  <p>everything work fine using this</p>
  
  <pre><code>$updatefild = array('count' =&gt; 20);
  $where = "id = '123'"; 
  
  echo $db-&gt;update("mytable",$updatefild, $where);
  </code></pre>
  
  <p>but i get problem when i want to update row with existing row, in <code>mysql_query</code> I usually use</p>
  
  <pre><code>mysql_query("update mytable set count=count+1 where id='123'");
  </code></pre>
  
  <p>how i achieve that use PDO ?</p>
  
  <p>thanks</p>