src/Titon/Db/Repository.php
protected function _processDelete(Query $query, array $options = []) {
        $options = $options + [
            'before' => true,
            'after' => true
        ];

        // Fetch ID
        $this->id = $id = $this->findID($query);

        if ($options['before']) {
            $event = $this->emit('db.preDelete', [$query, $id]);
            $state = $event->getState();

            if (!$state) {
                return 0;
            } else if (is_numeric($state)) {
                return (int) $state;
            }
        }

        // Update the connection context and execute the query
        $count = $this->getDriver()
            ->setContext('delete')
            ->executeQuery($query)
            ->save();

        // Only trigger callback if something was deleted
        if ($count && $options['after']) {
            $this->emit('db.postDelete', [$id, $count]);
        }

        return (int) $count;
    }
protected function _processDelete(Query $query, array $options = []) {
        $options = $options + [
            'before' => true,
            'after' => true
        ];

        // Fetch ID
        $this->id = $id = $this->findID($query);

        if ($options['before']) {
            $event = $this->emit('db.preDelete', [$query, $id]);
            $state = $event->getState();

            if (!$state) {
                return 0;
            } else if (is_numeric($state)) {
                return (int) $state;
            }
        }

        // Update the connection context and execute the query
        $count = $this->getDriver()
            ->setContext('delete')
            ->executeQuery($query)
            ->save();

        // Only trigger callback if something was deleted
        if ($count && $options['after']) {
            $this->emit('db.postDelete', [$id, $count]);
        }

        return (int) $count;
    }
protected function _processDelete ( Query $ query , array $ options = [ ] ) { $ options = $ options + [ 'before' => true , 'after' => true ] ; // Fetch ID $ this -> id = $ id = $ this -> findID ( $ query ) ; if ( $ options [ 'before' ] ) { $ event = $ this -> emit ( 'db.preDelete' , [ $ query , $ id ] ) ; $ state = $ event -> getState ( ) ; if ( ! $ state ) { return 0 ; } else if ( is_numeric ( $ state ) ) { return ( int ) $ state ; } } // Update the connection context and execute the query $ count = $ this -> getDriver ( ) -> setContext ( 'delete' ) -> executeQuery ( $ query ) -> save ( ) ; // Only trigger callback if something was deleted if ( $ count && $ options [ 'after' ] ) { $ this -> emit ( 'db.postDelete' , [ $ id , $ count ] ) ; } return ( int ) $ count ; }
Primary method that handles the processing of delete queries.

Before a delete is executed, a `preDelete` event will be triggered.
If a falsey value is returned, exit early with a 0. If a numeric value
is returned, exit early and return the number, which acts as a virtual
affected row count (permitting behaviors to short circuit the process).

Before the driver is queried, the connection context will be set to `delete`.

After a delete has executed successfully, a `postDelete` event will be triggered.

@param \Titon\Db\Query $query
@param mixed $options {
@type bool $before  Will trigger before callbacks
@type bool $after   Will trigger after callbacks
}
@return int The count of records deleted
Primary method that handles the processing of delete queries .