I'm not sure if I'm doing something bad or this is actually the expected behaviour from Cake.
The following is my code:
$tickets = $this->TicketsPrice->Ticket->find('all',array(
'contain'=> array(
'TicketsType' => array(
'conditions' => array(
'provider_id' => $provider_id,
),
),
),
)
);
And this is what I get:
Array
(
[0] => Array
(
[Ticket] => Array
(
[id] => 17
[name] => Telecabina
[tickets_type_id] => 9
)
[TicketsType] => Array
(
[id] => 9
[provider_id] => 5
[name] => Name
)
)
[1] => Array
(
[Ticket] => Array
(
[id] => 16
[name] => Pase General
[tickets_type_id] => 8
)
[TicketsType] => Array
(
[id] => 8
[provider_id] => 5
[name] => Name
)
)
[4] => Array
(
[Ticket] => Array
(
[id] => 13
[name] => Pase fin de semana
[tickets_type_id] => 7
)
[TicketsType] => Array
(
[id] =>
[provider_id] =>
[name] =>
)
)
I should not be getting ticket 4 in the array. Instead, since provider_id doesn't match, I get an empty TicketsType array. Is this the expected the result?