lithium\data\source\database\adapter\PostgreSql::_insertId PHP Method

_insertId() protected method

Gets the last auto-generated ID from the query that inserted a new record.
protected _insertId ( object $query ) : mixed
$query object The `Query` object associated with the query which generated
return mixed Returns the last inserted ID key for an auto-increment column or a column bound to a sequence.
    protected function _insertId($query)
    {
        $model = $query->model();
        $field = $model::key();
        $source = $model::meta('source');
        $sequence = "{$source}_{$field}_seq";
        $id = $this->connection->lastInsertId($sequence);
        return $id && $id !== '0' ? $id : null;
    }