title: PHP PDO Prepared statement query not updating record
body: <p>I am having a problem using PHP's PDO object to prepare an update statement and updating the record. I have taken the raw SQL query and ran it in phpMyAdmin with the params replaced by their values that are passed to the function. Which updates the record as intended. However, when ran from the script it does not update. It throws zero errors and it returns an errorInfo() reply of 00000, which to my understanding is PDO's way of saying all is well.  I know the PDO object works because it successfully inserts and selects records from the database, including the one I am trying to update. I understand this update function is ugly, I am just learning PDO.</p>
  
  <p>Obviously, this is coded in PHP5, using PDO.</p>
  
  <p>Class Function:</p>
  
  <pre><code>public function update($tbl_name, $where = null, $what = null)
      {
          if(is_array($where))
          {
              $where_str = 'where ';
              foreach($where as $key =&gt; $val)
              {
                  $where_str .= "{$key} = ':{$key}' and ";
              }
              $where_str = substr($where_str,0,-5);
  
              $what_str = 'set ';
              foreach($what as $key =&gt; $val)
              {
                  $what_str .= "`{$key}` = ':{$key}', ";
              }
              $what_str = substr($what_str,0,-2);
  
              $query_str = "update {$tbl_name} {$what_str} {$where_str} LIMIT 1;";
              $stmt = $this-&gt;dbh-&gt;prepare($query_str);
              echo '&lt;pre&gt;'.print_r($stmt, true).'&lt;/pre&gt;';
              foreach($what as $key =&gt; $val)
              {
                  if('date_time' === $key) continue;
                  $bind = $stmt-&gt;bindValue(":{$key}",$val);
                  echo ($bind ? 'true' : 'false')." :{$key}=",$val,'&lt;br/&gt;';
              }
              foreach($where as $key =&gt; $val)
              {
                  if('date_time' === $key) continue;
                  $bind = $stmt-&gt;bindValue(":{$key}",$val);
                  echo ($bind ? 'true' : 'false')." :{$key} ",$val,'&lt;br/&gt;';
              }
          }else{
              return false;
          }
          $this-&gt;dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          $exec = $stmt-&gt;execute();
          echo 'exec: '.($exec === true ? 'true:' : 'false:').':'.$exec.'&lt;br/&gt;';
  
          echo '&lt;pre&gt;';
          $stmt-&gt;debugDumpParams();
          echo '&lt;/pre&gt;';
  
          return $stmt-&gt;errorInfo();
      }
  </code></pre>
  
  <p>Called from session update/login script:</p>
  
  <pre><code>$where = array(
      'id' =&gt; $user['id'],
      );
  $what = array(
      'twitter_key'    =&gt; $oauth_token,
      'twitter_secret' =&gt; $oauth_token_secret
      );
  
  $update = $db-&gt;update('users', $where, $what);
  </code></pre>
  
  <p>Output from echos and print_r in class function and caller:</p>
  
  <pre><code>// print_r($stmt = $this-&gt;dbh-&gt;prepare($query_str)) output:
  PDOStatement Object
  (
      [queryString] =&gt; update users set `twitter_key` = ':twitter_key', `twitter_secret`     = ':twitter_secret' where id = ':id' LIMIT 1;
  )
  
  // output from the bing params and execution returns
  true :twitter_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXX
  true :twitter_secret=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  true :id 20
  exec: true:1
  
  // $stmt-&gt;debugDumpParams() output: 
  SQL: [111] update users set `twitter_key` = ':twitter_key', `twitter_secret` = ':twitter_secret' where id = ':id' LIMIT 1;
  Params:  3
  Key: Name: [12] :twitter_key
  paramno=-1
  name=[12] ":twitter_key"
  is_param=1
  param_type=2
  Key: Name: [15] :twitter_secret
  paramno=-1
  name=[15] ":twitter_secret"
  is_param=1
  param_type=2
  Key: Name: [3] :id
  paramno=-1
  name=[3] ":id"
  is_param=1
  param_type=2
  
  // print_r($stmt-&gt;errorInfo()) output:
  Array
  (
      [0] =&gt; 00000
  )
  </code></pre>