user1954544
user1954544

Reputation: 1687

Symfony2, Doctrine OneToOne relations

I have table (let's name it "First") with columns id, userID, moonID, typeID. And another table (let's name it "Second") where is also column "typeID" and TypeName (simple example, basicly this table is a huge storage of data).

I need create simple relations with this two (entities) tables such way that i can simple create new entries in "First" table and remove\edit them. But i don't want to del\add\edit entries from "Second" table. So "Second" is untouchable at all, we just select data from "Second" by typeID of "First". How can i do this?

I want to see two entities and controller. Please help me with it.

Upvotes: 1

Views: 5305

Answers (1)

Mirage
Mirage

Reputation: 31568

Its very easy have a look at here

http://doctrine-orm.readthedocs.org/en/latest/reference/association-mapping.html

You will know what to do. they have examples over there.

By default Doctrine wont delete the linked side unless you do onCascade="Delete"

You can use OnDelete= Null if you want to make the linked is to null in case of deletetion of owning side

Upvotes: 2

Related Questions