title: why pdo->lastInsertId() return 0 when i call STORED PROCEDURE in mysql?
body: <p>i need return id of last inseted row in my database :</p>
  
  <p>i have a class named  DatabaseHandler to use pdo</p>
  
  <pre><code>    &lt;?php class DatabaseHandler
      {
        private static $_mHandler;
  
        private function __construct()
        {}
  
        private static function GetHandler()
        {
          if (!isset(self::$_mHandler))
          {
            try
            {
              self::$_mHandler =
                new PDO(PDO_DSN, DB_USERNAME, DB_PASSWORD,
                        array(PDO::ATTR_PERSISTENT =&gt; DB_PERSISTENCY));
              self::$_mHandler-&gt;setAttribute(PDO::ATTR_ERRMODE,
                                             PDO::ERRMODE_EXCEPTION);
              self::$_mHandler-&gt;setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
            }
            catch (PDOException $e)
            {
              self::Close();
              trigger_error($e-&gt;getMessage(), E_USER_ERROR);
            }
          }
          return self::$_mHandler;
        }
  
        public static function Close()
        {
          self::$_mHandler = null;
        }
        public static function Execute($sqlQuery, $params = null)
        {
          try
          {
            $database_handler = self::GetHandler();
            $statement_handler = $database_handler-&gt;prepare('set names utf8; ' . $sqlQuery);
            $statement_handler-&gt;execute($params);
            $result=$database_handler-&gt;lastInsertId();              
          }catch(PDOException $e){
            self::Close();
            trigger_error($e-&gt;getMessage(), E_USER_ERROR);
          }
          return $result;         
        }?&gt;
  </code></pre>
  
  <p>and STORED PROCEDURE in mysql db  :</p>
  
  <pre><code> CREATE PROCEDURE `sp_users_Insert`(IN _username VARCHAR(50), IN _email VARCHAR(50), IN _password CHAR(32), IN _ip VARCHAR(15), IN _reg_date INT,  IN _ref_id MEDIUMINT)
      BEGIN
         INSERT INTO n_users
         (username , email , password , ip , reg_date , ref_id )
               VALUES(_username , _email , _password , _ip , _reg_date , _ref_id );
      END$$
  </code></pre>
  
  <p>and  when i call that like this , the database record is created but lastInsertId() return 0:</p>
  
  <pre><code>$username =me;
  $email=me@me.com;
  $password =msadss;
  $ip =12.0.0.1;
  $reg_date =1347284764;
  $ref_id =12;
  
  $sql = 'CALL `sp_users_Insert`(:username,:email,:password,:ip,:reg_date,:ref_id)';
  $params = array (':username' =&gt; $username, ':email' =&gt; $email, ':password' =&gt; $password, ':ip' =&gt; $ip, ':reg_date' =&gt; $reg_date, ':ref_id' =&gt; $ref_id);
  DatabaseHandler::Close(); 
  return DatabaseHandler::Execute($sql, $params);
  </code></pre>
  
  <p>What i am doing wrong?</p>