There's got to be a simpler way to do what I'm trying to do...
I have two pretty simple models.
Items, and subcategories.
An item can have any number of subcategories.
I don't really care how this is represented in the database, It Just
Needs To Work. I figured as a ORM layer, Doctrine would be all over
this.
I discovered, to a mild bit of annoyance, that I have to create the
intersection model myself (it seems to me that I should be able to
just tell Doctrine that my items and categories are many-many with
each other and it should do the rest, since I do not need any extra
fields in my intersection table...)
I have found plenty of examples of how to do this but none that really
talk through the /why/ of each line, which for someone brand new to
Doctrine's syntax, is sort of what I need.
Here is what I have so afr...
McSubcategory:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true}
relations:
McItem: {local: subcategory_id, foreign: item_id, refClass:
McItemSubcategory }
McItem:
actAs: { Timestampable: ~ }
columns:
name: { type: string(255), notnull: true, unique: true }
manufacturer_id: { type: integer, notnull: true }
relations:
McSubcategory: { local: item_id, foreign: subcategory_id,
refClass: McItemSubcategory }
McItemSubcategory:
columns:
item_id { type: integer }
subcategory_id { type: integer }
Despite my mild annoyance at having to create the intersection class
by hand, it did seem to work.
But, my ItemSubcategory SQL only has a constraint/foreign key on
items. It did not make a constraint/foreign key for subcategories.
Similarly, there is only an index on item_id, not subcategory_id.
So I must be doing something wrong... help?
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en