I have two tables, both very simple.
Desks:
id, name
Question_Tallies
id, created, desk_id, question_type_id
I'm trying to get the id, and created fields that are associated with
a single desk id. My query code is below:
$this->QuestionTally->contain('Desk.id = '.$desk_id);
$thisWeek = $this->QuestionTally->find('all', array('conditions' =>
'fields'=>array('QuestionTally.created', 'QuestionTally.id'),
'order'=>'QuestionTally.created ASC'));
The problem is that it's pulling all QuestionTally records, not just
the ones related to the specific Desk ID that I have requested. The
resultant SQL is as follows:
SELECT `QuestionTally`.`created`, `QuestionTally`.`id`, `Desk`.`id`
FROM `question_tallies` AS `QuestionTally` LEFT JOIN `desks` AS `Desk`
ON (`QuestionTally`.`desk_id` = `Desk`.`id` AND `Desk`.`id` = 2) ORDER
BY `created` ASC
1. I don't want to have Desk.id in the return results. Is this
possible, or does Containable automatically insert it if I specify to
contain by a field?
2. How would I get it to form a proper SQL quertion that only returns
results related to the desired desk_id?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---