To keep it simple with cake I have separate tables & models, but if I
need to share functionality between models, I use a behaviour.

What you're saying about using a custom base class for your models/
behaviours works well also.

Ultimately it depends on your data. eg. in my scenario I was going to
have a generic "media" table, which would hold videos, images,
documents (pdfs), etc, but I eventually moved each type into its own
tables, which made much more sense and a heck of a lot easier to
manage. I created a generic FileBehaviour which handles the handling
of files in general. Then as necessary I created an ImageBehaviour
extends FileBehaviour, which added code to deal with images, etc.

Hope that helps.

Cheers,
Adam


On Feb 16, 12:08 am, glastoveteran <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I'm building a content managed site with several slightly different
> types of record, but all of which feature a common set of fields e.g.
> title, summary, description, start_date, end_date, notes, etc.  Some
> types of record have one or two extra fields, e.g. location, price,
> etc.
>
> I've always wondered what's the best way of approaching this with
> cake, or indeed any framework?  To have a single database table,
> model, controller etc with a field and logic indicating the record
> type?  Or to implement each record type with a different table, model,
> controller etc?
>
> I guess the first option of one model involves less repetition, but
> how would you handle different record types having a slightly
> different validation rules based on the fact that sopme have extra
> fields that need to be validated?  Presumably you'd need to use a
> model beforeValidate() function instead of the standard validation
> array?
>
> The second option would seem to follow the MVC convention a little
> better and validation would be easier but seems to have more
> repetition.
>
> Looking at this in an object oriented way with classes you would I
> guess define a base class with the common characteristics and then
> extend / specialise this for other models.  How does that work with
> cake?
>
> Thanks all,
>
> Alex
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to