source/Spiral/ORM/Record.php
public function save(TransactionInterface $transaction = null, bool $queueRelations = true): int
    {
        /*
         * First, per interface agreement calculate entity state after save command being called.
         */
        if (!$this->isLoaded()) {
            $state = self::CREATED;
        } elseif (!$this->hasChanges()) {
            $state = self::UPDATED;
        } else {
            $state = self::UNCHANGED;
        }

        if (empty($transaction)) {
            /*
             * When no transaction is given we will create our own and run it immediately.
             */
            $transaction = $transaction ?? new Transaction();
            $transaction->store($this, $queueRelations);
            $transaction->run();
        } else {
            $transaction->addCommand($this->queueStore($queueRelations));
        }

        return $state;
    }
public function save(TransactionInterface $transaction = null, bool $queueRelations = true): int
    {
        /*
         * First, per interface agreement calculate entity state after save command being called.
         */
        if (!$this->isLoaded()) {
            $state = self::CREATED;
        } elseif (!$this->hasChanges()) {
            $state = self::UPDATED;
        } else {
            $state = self::UNCHANGED;
        }

        if (empty($transaction)) {
            /*
             * When no transaction is given we will create our own and run it immediately.
             */
            $transaction = $transaction ?? new Transaction();
            $transaction->store($this, $queueRelations);
            $transaction->run();
        } else {
            $transaction->addCommand($this->queueStore($queueRelations));
        }

        return $state;
    }
public function save ( TransactionInterface $ transaction = null , bool $ queueRelations = true ) : int { /*
         * First, per interface agreement calculate entity state after save command being called.
         */ if ( ! $ this -> isLoaded ( ) ) { $ state = self :: CREATED ; } elseif ( ! $ this -> hasChanges ( ) ) { $ state = self :: UPDATED ; } else { $ state = self :: UNCHANGED ; } if ( empty ( $ transaction ) ) { /*
             * When no transaction is given we will create our own and run it immediately.
             */ $ transaction = $ transaction ?? new Transaction ( ) ; $ transaction -> store ( $ this , $ queueRelations ) ; $ transaction -> run ( ) ; } else { $ transaction -> addCommand ( $ this -> queueStore ( $ queueRelations ) ) ; } return $ state ; }
Sync entity with database, when no transaction is given ActiveRecord will create and run it
automatically.

@param TransactionInterface|null $transaction
@param bool                      $queueRelations

@return int
Sync entity with database when no transaction is given ActiveRecord will create and run it automatically .