Friday, July 3, 2009

Containable grabbing empty data

Hello

Item belongsTo Order belongsTo Customer.

i'm grabbing data from Items Controller.

i need all items having Weight > 10 and Order.Date = $date
i also need to know who ordered that item.

here's my code

$date = date("Y-m-d");

$this->Item->find("all",
array(
"conditions" => array(
"Weight >" => 10
),
"contain" => array(
"Order" => array(
"conditions" => array(
"Date" => $date
),
"Customer"
)
)
)
);

here's my results

Array
(
[0] => Array
(
[Item] => Array
(
[Item_id] => 1105
[Order_id] => 20
[Code] => FOOFOOFOO
[Weight] => 15
)
[Order] => Array
(
[Order_id] => 20
[Date] => 2009-07-03
)
)

[1] => Array
(
[Item] => Array
(
[Item_id] => 1403
[Order_id] => 21
[Code] => ABCDEFG
[Weight] => 20
)
[Order] => Array
(
[Order_id] =>
[Date] =>
)
)
)

- there's no "Customer" model
- Items are loaded even if Item.Order does not respond to conditions

i can't find where's my error.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: