If you have specified correctly in each of your models, that:
City hasMany Neighborhood hasMany Location

and specified correctly the name of the table associated with each
model (if not the plural form of the model name), in this case,
Location model assumes locations table.

So in order to tell CakePHP that your Location models table is
"alllocations", add the useTable variable as specified in the
documentation at http://book.cakephp.org/view/436/useTable.

Then you should be able to use:
$myCityLocations = $this->City->find('all', array('conditions' => array
('City.id' => $myCityId), 'recursive' => 2));

!!! Correct me if I am wrong :) !!!

Best wishes,
   John

On Apr 22, 12:02 am, magicseth <nab...@magicseth.com> wrote:
> Hello, I am new to Cake from Rails,
>
> I currently have a City Model, a Neighborhood Model, and a Location Modle.
>
> Location belongs to a neighborhood, and a neighborhood belongs to a city.  I
> am trying to get all of the locations for a city using something like this:
>
> var $hasMany = array(
>     'Location' => array(
>         'className' => 'Location',
>         'finderQuery' => 'SELECT allLocations.*, FROM neighborhoods,
> allLocations WHERE {$__cakeID__$} = neighborhoods.city_id AND
> allLocations.neighborhood_id = neighborhoods.id '
>     )
> );
>
> Is this the right path?  I am running into an error:
>
> Missing Database Table
>
> Error: Database table locations for model Location was not found.
>
> How can I specify that the table is called allLocations?
>
> Thanks,
> -Seth
> --
> View this message in 
> context:http://www.nabble.com/finderQuery-help-tp23162894p23162894.html
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to