yii\db\ActiveRecord::insertInternal PHP Method

insertInternal() protected method

Inserts an ActiveRecord into DB without considering transaction.
protected insertInternal ( array $attributes = null ) : boolean
$attributes array list of attributes that need to be saved. Defaults to `null`, meaning all attributes that are loaded from DB will be saved.
return boolean whether the record is inserted successfully.
    protected function insertInternal($attributes = null)
    {
        if (!$this->beforeSave(true)) {
            return false;
        }
        $values = $this->getDirtyAttributes($attributes);
        if (($primaryKeys = static::getDb()->schema->insert(static::tableName(), $values)) === false) {
            return false;
        }
        foreach ($primaryKeys as $name => $value) {
            $id = static::getTableSchema()->columns[$name]->phpTypecast($value);
            $this->setAttribute($name, $id);
            $values[$name] = $id;
        }
        $changedAttributes = array_fill_keys(array_keys($values), null);
        $this->setOldAttributes($values);
        $this->afterSave(true, $changedAttributes);
        return true;
    }