Hi,

i'm quite new to cakePHP and i have a problem with a project started
by someone else.

I have a helper table for the gender of persons named "sexes" and a
related table (hasmany relation) with the translation for the
different languages "sex_translations".
Here is the content of my "Sex" model file:

class Sex extends AppModel
{
        var $name = 'Sex';
        var $hasMany = array(
        'SexTranslation' => array(
            'className'     => 'SexTranslation',
            'foreignKey'    => 'sex_id',
            'dependent'=> true
        ));
}

In a controller/view named "form" i try to fetch the gender of the
logged in person by including the model "Sex" with uses and
"findByID":

class FormsController extends AppController
{
        var $name = 'Form';
        var $uses = array('Person', 'Sex', 'Survey', 'Form', 'Answer',
'SurveyPeopleRelation', 'QuestionOption', 'Checkup');

...

      $this->Sex->bindModel(array('hasMany' => array('SexTranslation'
=> array('foreignKey'    => 'sex_id',
 
'fields' => array('SexTranslation.sex_id', 'SexTranslation.sex_name'),
 
'conditions' => 'SexTranslation.language_id = '.
                                                             $this-
>Session->read('ses_Language')))),false);


        $sex = $this->Sex->findById($person['sex_id']);         // $person
['sex_id'] is set to "1" in this case
        print_r($sex);

...

The resulting array is always empty. I've really no glance why.
The SQL queries are correct:

2 SELECT `Sex`.`id`, `Sex`.`name`, `Sex`.`short_name`,
`Sex`.`modified_by`, `Sex`.`modified` FROM `sexes` AS `Sex` WHERE
`Sex`.`id` = 1 LIMIT 1
3 SELECT `SexTranslation`.`sex_id`, `SexTranslation`.`sex_name` FROM
`sex_translations` AS `SexTranslation` WHERE
`SexTranslation`.`language_id` = 4 AND `SexTranslation`.`sex_id` =
(1)

When is use one of the other models on the same line (i.e. "Person" or
"Checkup") everything works fine:

        $sex = $this->Person->findById('1');
        print_r($sex);


I've already wasted lots of hours with this problem and i would be
really glad if someone could give me a hint, how to debug/solve this
issue.

thanks in advance

Dirk

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to