Model Associations:
- InfoFaturamento belongs to Contrato
- Contrato has many ContratoCliente
- ContratoCliente has many VwCliente
I want to fetch all VwClientes
where InfoFaturamento
equals an id passed by parameter. Is possible to do this without using joins option?
This is the code I tried. It's returning all the ContratoCliente
:
$test = $this->InfoFaturamento->Contrato->ContratoCliente->find('all', [
'contain' => [
'Contrato' => [
'InfoFaturamento' => [
'conditions' => [
'InfoFaturamento.id' => $idInfoFaturamento
]
]
]
],
]);
debug($test); die();
All the associations are set in the models.
I know I can do this with recursive option, but I don't like to use this because it returns lots of unnecessary data and it's slow. I could use joins too, but use joins is a good practice?