The example sql you entered will not work. There must be _some_ relationship between the area table and the location table or you cannot do a query!
Is the location geometry point contained within the area polygon? Is this expressable mathmatically? Rick On Aug 28, 7:02 am, Bryan Paddock <bryanpadd...@gmail.com> wrote: > Hey all, > I'm trying to execute a query including a table which is not related. I'm > not sure how I can go about doing this... > > 3 models in question: > > property (which has a location_id field) > location (which has a location_point field stored as geometry point) > area (which has an area_box field stored as a polygon) > > The location table is used to store single one to one locations for the > properties. The area table is used to store suburbs etc for another part of > the site. > > What I need to do now is to fetch all the properties which are inside a > certain area id. Sounds simple enough but I just cant figure it out. Area > has no relation to property and should not. > > The query would be something like this (I'm just writing out what the sql > should look like... I'm not using raw sql in my cake app) > > select > p.*, > a.*, > l.* > from > properties p, > areas a > left join > location l > on > p.location_id = l.id > where > a.id = 5 > and > MBRContains(a.area_box, l.location_point) > > so bascially fetch all properties where it's associated > locations.location_point is inside a specific unassociated areas.area_box > identified by its areas.id. > > In my property query conditions I have set array('Area.id' => 5) but because > it is not a directly related model cake isn't including that table in the > query so its failing with an "unknown table Area"... > > Even if I add "Area.area_box" to the 'fields' array for the paginator it > still doesn't know to fetch info from the area table. > > How do I tell cakephp to include an unrelated table into the query? var > $uses = array('Area') was useless.... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---