Get last insert id

@return int
542820
public function getLastInsertId()
    {
        $connection = $this->getConnection();
        $id = $connection->lastInsertId();
        if ($id < 1) {
            $fullTableName = $this->tableName;
            $fullUniqueIdName = $connection->quoteIdentifier($this->getUniqueId());
            $sql = /** @lang PostgreSQL */
                "SELECT $fullUniqueIdName 
                 FROM $fullTableName
                 LIMIT 1 
                 OFFSET (SELECT count($fullUniqueIdName)-1 FROM $fullTableName )";

            $id = $connection->fetchColumn($sql);
        }
        return $id;
    }
964681
public function lastInsertId(string $name = null): string
    {
        $this->connect();

        return $this->pdo->lastInsertId($name);
    }
1325538
public int lastInsertedId (Connection conn, Statement istmt, String table, String column)
        throws SQLException
    {
        // if this JDBC driver supports getGeneratedKeys, use it!
        if (istmt != null && conn.getMetaData().supportsGetGeneratedKeys()) {
            ResultSet rs = istmt.getGeneratedKeys();
            if (rs.next()) {
                return rs.getInt(column);
            }
        }
        return fetchLastInsertedId(conn, table, column);
    }
1260141
public function insertId ($name = null)
		{
			if ($name === null) {
				return $this->database->lastInsertId();
			} else {
				return $this->database->lastInsertId($name);
			}
		}
52761
public function lastInsertedId()
    {
        $query = "MATCH (n) RETURN MAX(id(n)) AS lastIdCreated";

        $statement = $this->getCypherQuery($query, []);
        $result = $statement->getResultSet();

        return $result[0][0];
    }
1110007
public function lastInsert()
	{
		$query = $this->connection->createSelect();
		$query->setQuery('*:*');
		$query->setFields(array('timestamp'));
		$query->addSort('timestamp', 'DESC');
		$query->setRows(1);
		$query->setStart(0);

		$results = $this->connection->execute($query);
		foreach ($results as $document)
		{
			foreach ($document as $field => $value)
			{
				$result = $value;
				return $result;
			}
		}
	}
1196549
protected function getLastChildPosition()
    {
        $lastChild = $this->getLastChild([$this->getPositionColumn()]);

        return (is_null($lastChild) ? 0 : $lastChild->position);
    }
222647
public function getLastIndice()
    {
        $last = $this->getFirstIndice() - 1 + $this->getLimit();
        if ($last > $this->getTotal()) {
            $last = $this->getTotal();
        }

        return $last;
    }
668487
public function getLastSequenceNumber()
    {
        if (count($this->events) === 0) {
            return $this->lastCommittedSequenceNumber;
        }
        if ($this->lastSequenceNumber === null) {
            $event = end($this->events);
            $this->lastSequenceNumber = $event->getSequenceNumber();
        }
        return $this->lastSequenceNumber;
    }
700676
public function insert_id()
    {
        if (!$this->connection) {
            $this->last_error_id = "db_server_conn_error";
            return false;
        }
        
        if ($this->last_query_is_insert) {
            if (!$this->statement) {
                return null;
            }
            
            if (!sqlsrv_next_result($this->statement)) {
                $this->last_error = $this->sys_get_errors();
                $this->last_error_id = "db_query_error";
                
                trigger_error($this->last_error, E_USER_ERROR);
                return false;
            }
            
            $id = null;
            
            if (@sqlsrv_fetch($this->statement)) {
                $id = sqlsrv_get_field($this->statement, 0);
            }
            
            return $id;
        }
        
        $this->statement = @sqlsrv_query($this->connection, "SELECT SCOPE_IDENTITY() AS IID");
        if (!$this->statement) {
            $this->last_error = $this->sys_get_errors();
            $this->last_error_id = "db_query_error";
            
            trigger_error($this->last_error, E_USER_ERROR);
            return false;
        }
        
        if (!$this->fetch_row()) {
            $this->last_error_id = "db_query_error";
            return false;
        }
        
        $id = $this->field_by_name("IID");
        
        $this->free_result();
        
        return $id;
    }
333687
public function last()
    {
        $where = $this->where;

        $whereData = $this->where_data_binding;

        // We count all.
        $c = $this->count();

        $this->where = $where;

        $this->where_data_binding = $whereData;

        return $this->jump($c - 1)
            ->take(1)->first();
    }
588713
public function lastInsertId($name)
    {
        // check if a valid name and sequence exists
        if (! $name || ! $this->exists($name)) {
            return 0;
        }

        return $this->connection->selectOne("select {$name}.currval as id from dual")->id;
    }
353554
public function getLastUpdate()
    {
        try {
            $stmt = $this->statementContainer->prepare(
                "SELECT value FROM {$this->prefix}meta
                    WHERE name = :name"
            );
            $stmt->execute(array(
                ":name" => MetaData::LASTMODIFIED,
            ));
            $result = $stmt->fetch();
            if ($result === false) {
                throw new DataBackendException();

            }
            $stmt->closeCursor();
            return $result["value"];

        } catch (\PDOException $e) {
            $stmt->closeCursor();
            throw new DataBackendIOException($e->getMessage(), $e->getCode(), $e);

        }
    }
485050
public function findLast()
    {
        $sql = sprintf("SELECT id, name, created_at FROM {$this->tableName} ORDER BY id DESC LIMIT 1");
        if ($row = $this->adapter->selectRow($sql)) {
            return $this->_makeModel($row);
        }

        return null;
    }
174980
public function nextId()
    {
        $timestamp = time() - static::BASE_TIME;

        if ($this->lastTimestamp >= $timestamp) {
            $timestamp = $this->lastTimestamp;

            $sequence = ++ $this->sequence;

            if ($sequence > 0x7ff) {
                $this->lastTimestamp = ++ $timestamp;

                $sequence = $this->sequence = 0;
            }
        } else {
            $this->lastTimestamp = $timestamp;

            $sequence = $this->sequence = 0;
        }

        return ($timestamp << 32) | $this->mask | ($sequence & 0x7ff);
    }
269087
public function last()
    {
        $lastIndex = (count($this->source) - 1);
        if (isset($this->source[$lastIndex])) {
            return $this->source[$lastIndex];
        }

        return null;
    }
971886
public function insert()
    {
        $this->SQLTemplate('insert')->execute();

        return
            $this->hasInsertOption('ignore') ? null :
            $this->owner->lastID();
    }