Hi there,

I'm developing a romantic matchmaking app and just went into a
problem, which concerns two models:

User (id, gender)
Score (id, male_id, female_id, score)

A user is either a male or a female. A score (the HABTM middle model)
is an indicator of compatibility between a male and a female. If the
score is greater than 3, we suppose the users indicated by male_id and
female_id are a good match. Below is what I have now:

class User extends AppModel {
        var $name = 'User';

        var $hasAndBelongsToMany = array(
                'MaleMatch' => array(
                        'className' => 'User',
                        'joinTable' => 'scores',
                        'with' => 'Score',
                        'foreignKey' => 'female_id',
                        'associationForeignKey' => 'male_id',
                        'conditions' => array(
                                'Score.score >=' => 3
                        )
                ),
                'FemaleMatch' => array(
                        'className' => 'User',
                        'joinTable' => 'scores',
                        'with' => 'Score',
                        'foreignKey' => 'male_id',
                        'associationForeignKey' => 'female_id',
                        'conditions' => array(
                                'Score.score >=' => 3
                        )
                )
        );

The problem is that 'MaleMatch' and 'FemaleMatch' are separated,
because their 'foreignKey' and 'associationForeignKey' are opposite.
This leads to great inconvenience to the developer.

Any suggestions on how to merge the two into just one 'Match' ?

BTW: It may not be a good idea to fix this in Model::afterFind(), for
it doesn't make Model::contain() any more convenient.

Many thanks!
--~--~---------~--~----~------------~-------~--~----~
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