I think you can create a HABTM onto "itself" by aliasing. Look at the
full definition of the relationship in the cookbook and you will find
that you can call the related table something other than it's real
name.

I don't really get what you want to achieve. At first glance I think I
would have done something quite different. Partly because of the
headache I get from building a mental picture of this kind of data-
structure. E.g. a relationship that is only relevant for half the
possible values in that emun field. What about a teacher that has a
child in school... that sort of thing.



On Feb 19, 8:24 pm, ggcakephp <[email protected]> wrote:
> Hi.. I have a problem with HABTM relation...
> I have two types of users "parent" and "student"(child of the parent)
> stored in one table named "users". Field in this table named "type"
> defines which type of user it is.
>
> Fields in table "users":
>   `id` int(11)
>   `type` enum('a','t','p','s') //a - admin, t - teacher, p - parent, s
> - student(child)
>   `name` varchar(60)
>   `surname` varchar(60)
>   `login` varchar(16)
>   `password` char(40)
>
> Fields in table used to join named "childrensparents"
>   `id` int(11) auto_increment,
>   `parent_id` int(11) // foreign key identifying unique user from
> table "users" (which has "type" field set as 'p')
>   `child_id` int(11) // foreign key identifying unique user from table
> "users" (which has "type" field set as 's')
>
> ...so both foreign keys are "linked" to the same table ("user")
>
> I have to define parent-child relation in "User" model, assuming that
> one parent can have many children(students) and one child(student)
> belongs to one or more parents....
>
> I have no idea how to define "$hasAndBelongsToMany" relation in this
> case (being honest i never used this type of ralation before, i'm
> working with cakePHP since two months, so many things are new to my)
>
> I'll be grateful for any help....
> Thankyou to all in advance....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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