Hierarchical Models and associations?

2007-03-26 Thread TekJansen

Is it possible to create a hierarchy of model classes? Cake doesn't
seem too happy when I try.

What I mean is that I have a table, let's say People. I've created
two models which use this table, let's say Man and Woman. The
reason they're different is that they have different validation rules,
business rules, controllers, etc.

So far so good, but now I have a child object type, say a Hat. A hat
belogsTo a Man OR a Woman through a person_id foreign key. I
assumed I could have the Man and Woman model classes extend a
Person class, which would extend AppModel and define the belongsTo
relationship. However this doesn't work.

Is there an easy solution to this type of problem? I want to avoid
separate ManHat and WomanHat models for obvious reasons. I also
want to avoid separate tables for Men and Women since they really are
the same thing.

Any advice is appreciated.
Best Regards...


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Hierarchical Models and associations?

2007-03-26 Thread TekJansen

One small correction - below, when I said I hoped I could define the
belongsTo relationship at some superclass level and have it
inherited by subclasses, I meant, at least for my hypothetical
example, the hasMany relationship.

thanks.

On Mar 26, 8:06 pm, TekJansen [EMAIL PROTECTED] wrote:
 I assumed I could have the Man and Woman model classes extend a
 Person class, which would extend AppModel and define the belongsTo
 relationship.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---