src/Koldy/Db/Model.php
public static function create(array $data): Model
    {
        $insert = new Insert(static::getTableName(), $data, static::getAdapterConnection());
        $insert->exec();

        if (static::$autoIncrement) {
            // ID should be fetched if $data contains ID, so, let's check
            if (is_string(static::$primaryKey) && isset($data[static::$primaryKey])) {
                // there there, we already have it, let's do nothing
            } else {
                $data[static::$primaryKey] = static::getLastInsertId();
            }
        }

        return new static($data);
    }
public static function create(array $data): Model
    {
        $insert = new Insert(static::getTableName(), $data, static::getAdapterConnection());
        $insert->exec();

        if (static::$autoIncrement) {
            // ID should be fetched if $data contains ID, so, let's check
            if (is_string(static::$primaryKey) && isset($data[static::$primaryKey])) {
                // there there, we already have it, let's do nothing
            } else {
                $data[static::$primaryKey] = static::getLastInsertId();
            }
        }

        return new static($data);
    }
public static function create ( array $ data ) : Model { $ insert = new Insert ( static :: getTableName ( ) , $ data , static :: getAdapterConnection ( ) ) ; $ insert -> exec ( ) ; if ( static :: $ autoIncrement ) { // ID should be fetched if $data contains ID, so, let's check if ( is_string ( static :: $ primaryKey ) && isset ( $ data [ static :: $ primaryKey ] ) ) { // there there, we already have it, let's do nothing } else { $ data [ static :: $ primaryKey ] = static :: getLastInsertId ( ) ; } } return new static ( $ data ) ; }
Insert the record in database with given array of data

@param array $data pass array of data for this model \Koldy\Db\Model

@return Model
@throws Exception
@throws Json\Exception
@throws Query\Exception
@throws \Koldy\Exception
Insert the record in database with given array of data