title: PDO lastInsertId() always return 0
body: <p>I've come across with a problem. My framework was working just fine with PHP 5.3.0. I upgraded my PHP version to PHP 5.4.x and I started to have few issues with some parts of my framework.</p>
  
  <p>After PHP version upgrade, <code>PDO lastInsterId()</code> always returns <code>0</code>.</p>
  
  <p>I have auto-increment field called <code>id</code>.
  It is adding the data to database without any problems.</p>
  
  <p>For some reason I keep getting 0 as last insert id.</p>
  
  <p>Here is my code;</p>
  
  <p><strong>databaseobjects.php</strong></p>
  
  <pre><code>public static function create () {
          global $db;
          $attributes = self::sanitize(static::$fields);
  
          $sql  = "INSERT INTO ".PREFIX.static::$table_name." (";
          $sql .= join(", ", array_keys($attributes));
          $sql .= ") VALUE (:";
          $sql .= join(", :", array_keys($attributes));
          $sql .= ")";
  
          return ($db-&gt;crudQuery($sql, $attributes)) ? true : false;
      }
  
  public static function lastInsertID () {
          global $db;
          return $db-&gt;handler-&gt;lastInsertId();
      }
  </code></pre>
  
  <p><strong>database.php</strong></p>
  
  <pre><code>public function crudQuery($sql, $data) {
          $sth = $this-&gt;handler-&gt;prepare($sql);
          return $sth-&gt;execute($data);
      }
  </code></pre>
  
  <p>First <code>create()</code> method is called, then <code>crudQuery()</code> method is called.
  As I mentioned before, I can add the data successfully to MySQL database.
  Unfortunately when I call <code>lastInsterID()</code> method, it always returns 0.</p>
  
  <p>I will be really glad if you can help me out with this problem before I will get the last ID with SQL Query (:</p>