tags:

views:

378

answers:

2

Hi, I've been looking at Doctrine and it seems like a good way to manage models in my OO PHP application.

I would like to create Models that have some optional properties. Rather than having null values in my database, I would like to create separate tables for some (all?) of these properties and give them a foreign key of the node which they relate to. Then when querying the data, perform outer joins on the optional values.

Is there a way to implement something like this in Doctrine?

I've not looked at the documentation thoroughly yet but can one model effectively be defined within multiple tables? The examples I've seen did not appear to mention this.

I hope that makes sense!

Any advice appreciated.

Thanks.

A: 

Use one-to-many relation with properties table.

ModelProperty
~~~~~~~~~~~~~~~~~~~~
modelproperty_id
modelproperty_model_id
modelproperty_property_name
modelproperty_property_value

Is that what you are going to achieve?

FractalizeR
A: 

Doctrine supports both inner and left (outer) joins as part of the Doctrine Query Language. You can also write your own custom queries if you need to but still use the models for the results.

Doctrine's join documentation

Chris Williams