You are putting:
$this->Ticket->bindModel(array('belongsTo' => array('Item' =>
array('foreignKey' => 'deal_id'))));
instead of :
$this->Ticket->bindModel(array('belongsTo' => array('Item' =>
array('foreignKey' => 'item_id'))));
it's a copy and paste error.
HTH,
- Dardo Sordi.
On Jan 18, 2008 9:39 PM, phpjoy <[EMAIL PROTECTED]> wrote:
>
> I wonder how I could make a simple query to work through bind(), and
> not use a custom query.
>
> I'm binding two models for a model:
> $this->Ticket->bindModel(array('belongsTo' => array('Deal' =>
> array('foreignKey' => 'deal_id'))));
> $this->Ticket->bindModel(array('belongsTo' => array('Item' =>
> array('foreignKey' => 'deal_id'))));
>
> The resulting query I get is this:
> SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
> `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Ticket`.`deal_id` =
> `Item`.`id`) WHERE `Ticket`.`user_id` = 1
>
> Now, instead of:
> `Item` ON (`Ticket`.`deal_id` = `Item`.`id`)
> I need:
> `Item` ON (`Deal`.`item_id` = `Item`.`id`)
>
> Which gives this query:
> SELECT `Ticket`.`id`, `Deal`.`file`, `Item`.`title` FROM `tickets` AS
> `Ticket` LEFT JOIN `deals` AS `Deal` ON (`Ticket`.`deal_id` =
> `Deal`.`id`) LEFT JOIN `items` AS `Item` ON (`Deal`.`item_id` =
> `Item`.`id`) WHERE `Ticket`.`user_id` = 1
>
> I tried binding item to deal, and CakePHP made 200 queries instead.
> That didn't work too well.
> Any ideas how I could make a slim query with CakePHP, without using
> query()?
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---