[TYPO3-mvc] sub-models within the model table
Martin Kutschker
masi-no at spam-typo3.org
Mon May 17 16:10:49 CEST 2010
Martin Kutschker schrieb:
> Hi!
>
> Let's assume we have a customer model. It has two addresses one for shipping and one for billing. We
> further assume that we don't need tha address on it's own (quite likely in a shop application) and
> so we don't want to create a separate address table.
>
> The table looks like this:
>
> id
> name
> shipping_address
> shipping_postcode
> shipping_city
> billing_address
> billing_postcode
> billing_city
>
> My idea is now to model those two addresses as models with the customer model rather then a bunch of
> unrelated properties of the customer. If the address sub-model is general enough it could be reused
> in any other model (and table).
I think I found the pattern for this kind of setup: "embedded value". The fields of the model are
stored within the table of the parent object. Its always useful if you don't need access/manipulate
the child objects on their own (eg a common structure in shops).
Masi
More information about the TYPO3-project-typo3v4mvc
mailing list