Skip to content

Remove simple relationship #113

@vladrolandomihai

Description

@vladrolandomihai

I can't figure out how to remove a simple relationship. Suppose I have a Person Entity which has a collection of friends (also Person). Say John is friend with Jimmy. I did the following:

$john->removeFriend($jimmy); // already retrieved from db
$em->flush();

and the removeFriend function in Person class looks like this:

function removeFriend($person) {
    if ($this->friends->contains($person)) {
        $this->friends->remove($person);
    }
}

The in-memory collection is updated. John is not friend with Jimmy anymore. However, this is not persisted into the db.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions