src/Sql/Manager.php
public function delete($object, $meta=null)
    {
        $query = new Query\Criteria();

        if (!is_object($object)) {
            throw new \BadMethodCallException("Please use deleteTable()");
        } 

        if ($meta) {
            $meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
        } else {
            $meta = $this->mapper->getMeta(get_class($object));
        }

        if (!$meta->canDelete) {
            throw new Exception("Meta {$meta->id} prohibits delete");
        }

        event_before: {
            if (isset($meta->on['beforeDelete'])) {
                foreach ($meta->on['beforeDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
            }
            if (isset($this->on['beforeDelete'])) {
                foreach ($this->on['beforeDelete'] as $cb) { $cb($object, $meta); }
            }
        }

        $query->where = $meta->getIndexValue($object);
        $return = $this->executeDelete($meta, $query);

        event_after: {
            if (isset($meta->on['afterDelete'])) {
                foreach ($meta->on['afterDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
            }
            if (isset($this->on['afterDelete'])) {
                foreach ($this->on['afterDelete'] as $cb) { $cb($object, $meta); }
            }
        }

        return $return;
    }
public function delete($object, $meta=null)
    {
        $query = new Query\Criteria();

        if (!is_object($object)) {
            throw new \BadMethodCallException("Please use deleteTable()");
        } 

        if ($meta) {
            $meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
        } else {
            $meta = $this->mapper->getMeta(get_class($object));
        }

        if (!$meta->canDelete) {
            throw new Exception("Meta {$meta->id} prohibits delete");
        }

        event_before: {
            if (isset($meta->on['beforeDelete'])) {
                foreach ($meta->on['beforeDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
            }
            if (isset($this->on['beforeDelete'])) {
                foreach ($this->on['beforeDelete'] as $cb) { $cb($object, $meta); }
            }
        }

        $query->where = $meta->getIndexValue($object);
        $return = $this->executeDelete($meta, $query);

        event_after: {
            if (isset($meta->on['afterDelete'])) {
                foreach ($meta->on['afterDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
            }
            if (isset($this->on['afterDelete'])) {
                foreach ($this->on['afterDelete'] as $cb) { $cb($object, $meta); }
            }
        }

        return $return;
    }
public function delete ( $ object , $ meta = null ) { $ query = new Query \ Criteria ( ) ; if ( ! is_object ( $ object ) ) { throw new \ BadMethodCallException ( "Please use deleteTable()" ) ; } if ( $ meta ) { $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; } else { $ meta = $ this -> mapper -> getMeta ( get_class ( $ object ) ) ; } if ( ! $ meta -> canDelete ) { throw new Exception ( "Meta {$meta->id} prohibits delete" ) ; } event_before : { if ( isset ( $ meta -> on [ 'beforeDelete' ] ) ) { foreach ( $ meta -> on [ 'beforeDelete' ] as $ cb ) { $ cb = [ $ object , $ cb ] ; $ cb ( ) ; } } if ( isset ( $ this -> on [ 'beforeDelete' ] ) ) { foreach ( $ this -> on [ 'beforeDelete' ] as $ cb ) { $ cb ( $ object , $ meta ) ; } } } $ query -> where = $ meta -> getIndexValue ( $ object ) ; $ return = $ this -> executeDelete ( $ meta , $ query ) ; event_after : { if ( isset ( $ meta -> on [ 'afterDelete' ] ) ) { foreach ( $ meta -> on [ 'afterDelete' ] as $ cb ) { $ cb = [ $ object , $ cb ] ; $ cb ( ) ; } } if ( isset ( $ this -> on [ 'afterDelete' ] ) ) { foreach ( $ this -> on [ 'afterDelete' ] as $ cb ) { $ cb ( $ object , $ meta ) ; } } } return $ return ; }
Delete an object from the database

delete ( $object )
delete ( $object, $meta )

@return void
Delete an object from the database