First of all: I have reasonable PHP4/5 experience and have been
playing with Django for some time, which directed me to CakePHP to
combine the two :-)
Currently, I want to start my very own CakePHP app (or must I say:
'bake' :), but I've got one nasty dependency that I cannot resolve.
Imagine a bookshelf: one might want to place books on them, but also
other things like cd's, plants or whatnot. These objects are ordered.
As each object has it's own set of properties, I would opt for
creating various models:
- book: title, author, width, height
- cd: title, band
- plant: type, size
- whatnot: ...
But they have one thing in common: they are located on the same
bookshelf. The standard hasMany, hasOne and belongsTo relations do not
fit here, as they ignore order and the hasAndBelongsToMany also does
not fit here as it requires the objects on the shelf to be of the same
kind.
In the Bakery I came across OrderedBehavior, which implements a nice
list, but again requiring all objects to be of the same type.
Normally, I would generate a super-class and make the Books, CDs,
Plants subclasses but as far as I can see CakePHP does not really
support inheritance/subclassing? Another way is to create a
'BookshelfObject' that can be placed on the bookshelf, containing the
type and id of the actual object and add a function to return the
actual object. The latter however does not feel completely right in a
MVC approach? Also, using this approach CakePHP cannot tell on which
shell an object is located, as (e.g.) there is no book_id pointing to
id, instead, there is a BookshelfObject telling a 'book' (type, for
example an enum) with 'id' (integer, but not a foreign key) x is
located on the shelf.
Is this requirement/dependency too specific that I'd better create
something by hand, or is there a way to make use of all the nice power
of CakePHP? Can someone point me in the right direction?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment