Cake doesn't do joins automatically with hasOne/Many or belongsTo
associations. Instead, it fetches the data from the first table, then
it performs additional queries to get the associated data.

You'll have to specify the joins manually if you want to base a find
condition on associated data:
http://book.cakephp.org/view/1047/Joining-tables

On Jun 7, 3:28 pm, jamc <[email protected]> wrote:
> Hello Friends, I want to do a query like this:
>
> $Anuncio->Inmueble->Zona
>
> where Anuncio hasOne Inmueble and Inmueble belongsTo Zona,
> obtain data works perfect, but the problem is to filter Anuncios
> according to one Zona.ciudad_id
> for that I am doing this:
> $this->Anuncio->find('all', array('conditions' => array(
>                                               'Zona.ciudad_id' =>
> $idCiudad
> )))
>
> where I can get $ciudadId with 'GET'.
>
> do it that way gives me the following error:
>
> SQL Error: 1054: Unknown column 'Zona.ciudad_id' in 'where clause'
>
> can someone please tell me how I can make that kind of conditions?
>
> Note: Excuse me, but I do not write English very well

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to