Ouzo\Db::lastInsertId PHP Method

lastInsertId() public method

public lastInsertId ( $sequence )
    public function lastInsertId($sequence)
    {
        $lastInsertId = $this->_dbHandle->lastInsertId($sequence);
        if (!$lastInsertId) {
            throw PDOExceptionExtractor::getException($this->_dbHandle->errorInfo(), "Cannot get sequence value: {$sequence}");
        }
        return $lastInsertId;
    }

Usage Example

Beispiel #1
0
 public function insert($sequence = '')
 {
     $this->execute();
     return $sequence ? (int) $this->_db->lastInsertId($sequence) : null;
 }