src/Model/Service/SqlService.php
public function unlinkAll($relation, $primary)
    {
        if (is_null($this->schema)) {
            throw SystemException::forNoSchema();
        }

        $name = $this->schema->getName();
        $relations = $this->schema->getRelations();
        $table = $name . '_' . $relation;

        if (!isset($relations[$table])) {
            throw SystemException::forNoRelation($name, $relation);
        }

        $relation = $relations[$table];

        $filter = sprintf('%s = %%s', $relation['primary1']);

        return $this
            ->resource
            ->search($table)
            ->addFilter($filter, $primary)
            ->getCollection()
            ->each(function ($i, $model) use (&$table) {
                $model->remove($table);
            })
            ->get();
    }
public function unlinkAll($relation, $primary)
    {
        if (is_null($this->schema)) {
            throw SystemException::forNoSchema();
        }

        $name = $this->schema->getName();
        $relations = $this->schema->getRelations();
        $table = $name . '_' . $relation;

        if (!isset($relations[$table])) {
            throw SystemException::forNoRelation($name, $relation);
        }

        $relation = $relations[$table];

        $filter = sprintf('%s = %%s', $relation['primary1']);

        return $this
            ->resource
            ->search($table)
            ->addFilter($filter, $primary)
            ->getCollection()
            ->each(function ($i, $model) use (&$table) {
                $model->remove($table);
            })
            ->get();
    }
public function unlinkAll ( $ relation , $ primary ) { if ( is_null ( $ this -> schema ) ) { throw SystemException :: forNoSchema ( ) ; } $ name = $ this -> schema -> getName ( ) ; $ relations = $ this -> schema -> getRelations ( ) ; $ table = $ name . '_' . $ relation ; if ( ! isset ( $ relations [ $ table ] ) ) { throw SystemException :: forNoRelation ( $ name , $ relation ) ; } $ relation = $ relations [ $ table ] ; $ filter = sprintf ( '%s = %%s' , $ relation [ 'primary1' ] ) ; return $ this -> resource -> search ( $ table ) -> addFilter ( $ filter , $ primary ) -> getCollection ( ) -> each ( function ( $ i , $ model ) use ( & $ table ) { $ model -> remove ( $ table ) ; } ) -> get ( ) ; }
Unlinks all references in a table from another table

@param *string $relation
@param *int    $primary

@return array
Unlinks all references in a table from another table