> 1. You can use the Cake associations to do this. Have one table user
> and one table author. The author table has a user_id field, and you
> would set up 'author belongsTo user' and 'user hasOne author'. (Note
> that we've lost the semantic meaning of belongsTo and hasOne here --
> they don't mean anything in the way that the city/road example did). Do
> the same for the publisher.

hi anselm !

thanks very much for your detailed answer,
you hit the point, mate !

I went for the first solution, except that i configured associations
vice versa to your suggestion.
But as you stated above, the semantic meaning doesn't describe the
model relations anyways.

Author/Publisher hasOne User
(can be regarded as a "webuser" -identity)

User belongs to Author / Publisher

this was the tricky part, see the code:

class User extends AppModel {

        var $name = 'User';

        var $belongsTo = array(
                        'Author' =>
                                array('className' => 'Author',
                                                'foreignKey' => 'author_id',
                                                'conditions' => '',
                                                'fields' => '',
                                                'order' => '',
                                                'counterCache' => ''
                                ),

                        'Publisher' =>
                                array('className' => 'Publisher',
                                                'foreignKey' => 'publisher_id',
                                                'conditions' => '',
                                                'fields' => '',
                                                'order' => '',
                                                'counterCache' => ''
                                ),

        );

}

it works fine, but it's not perfect, because every user instance
is associated to both, Author AND Publisher.

I tried to make use of the binding conditions:

'conditions' => 'usergroup' = A
and
'conditions' => 'usergroup' = P

While User.usergroup is a CHAR field in the User table.
But it lead to no results, because the conditions were
concatenated with AND. Is it possible to OR / XOR the
array elements ?

Another (minor) drawback is that in the User table
either the field 'publisher_id' or 'author_id' remains unused.

But anyways, i can live with it for the time being,
i don't feel like digging into new features like behaviours,
though it sounds like an interesting option.

allthebest, jyrgen


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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