Hello all, 

So I've been looking for a few days on how I can solve my problem I've got.

Basically I'm writing an Entity-Attribute-Value system and I'd like to have 
a variable targetEntity on an association (I think that's want I want...) 
here's the situation:

I have (for brevity) two entities: User and Car
I have a table for Attributes
I have a table for AttributeValues
I have a table for Users
I have a table for Cars

I'd like to end up with four total entities in the end, User, Car, 
Attribute, and AttributeValue

In my Attribute's table I have columns as such: [ id | name | type ] where 
type is "user" or "car"
In my AttruibuteValues table I have columns as such: [ id | value | 
attribute_id | owner_id | type ] where type is "user" or "car" and the 
owner id is the id of either a User or a Car

When I'm working with a user, I'd like to be able to get a collection of 
the user's AttributeValues via an association with the AttributeValues 
table "join attributeValues on (owner_id=user.id and type="user")"
When I'm working with an AttributeValue, I'd like to be able to get the 
owner associated with it.

Basically it's as if I wanted a conditional association, if the 
AttributeValue.type = "user" load the entity from Users where user.id = 
attributeValue.owner_id, if the AttributeValue.type = "car" load the entity 
from Cars where car.id = attributeValue.owner_id.

Is something like this possible? is there a better way to go about doing 
this?

I'm not having an issue with going from owner (user, car) to 
attributeValue, the issue is that I want to be able to go from the 
attributeValue to the owner.

Any help or advice is greatly appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to