src/Koldy/Db/Model.php
public static function getLastInsertId(string $keyName = null)
    {
        if (static::$autoIncrement) {
            if (is_string(static::$autoIncrement)) {
                $keyName = static::$autoIncrement;
            } else if (is_string(static::$primaryKey)) {
                $keyName = static::getTableName() . '_' . static::$primaryKey . '_seq';
            }

            return static::getAdapter()->getLastInsertId($keyName);
        } else {
            throw new Exception('Can not get last insert ID when model ' . get_called_class() . ' doesn\'t have auto_increment field');
        }
    }
public static function getLastInsertId(string $keyName = null)
    {
        if (static::$autoIncrement) {
            if (is_string(static::$autoIncrement)) {
                $keyName = static::$autoIncrement;
            } else if (is_string(static::$primaryKey)) {
                $keyName = static::getTableName() . '_' . static::$primaryKey . '_seq';
            }

            return static::getAdapter()->getLastInsertId($keyName);
        } else {
            throw new Exception('Can not get last insert ID when model ' . get_called_class() . ' doesn\'t have auto_increment field');
        }
    }
public static function getLastInsertId ( string $ keyName = null ) { if ( static :: $ autoIncrement ) { if ( is_string ( static :: $ autoIncrement ) ) { $ keyName = static :: $ autoIncrement ; } else if ( is_string ( static :: $ primaryKey ) ) { $ keyName = static :: getTableName ( ) . '_' . static :: $ primaryKey . '_seq' ; } return static :: getAdapter ( ) -> getLastInsertId ( $ keyName ) ; } else { throw new Exception ( 'Can not get last insert ID when model ' . get_called_class ( ) . ' doesn\'t have auto_increment field' ) ; } }
If you statically created new record in database to the table with auto
incrementing field, then you can use this static method to get the
generated primary key

@param null|string $keyName

@return int|string
@throws Exception
@throws \Koldy\Config\Exception
@throws \Koldy\Exception
@example

if (User::create(array('first_name' => 'John', 'last_name' => 'Doe'))) {
echo User::getLastInsertId();
}
If you statically created new record in database to the table with auto incrementing field then you can use this static method to get the generated primary key