J. Eckert was right. If you setup your associations that way, you
should only get 1 city, 1 region and 1 state for each house.

Here's a zip file with a complete example of how to pull it off:

http://www.experiment621.com/stuff/test_geography.zip

The zip file includes:
----------------------------------------------
- SQL file to create test database called "test_geography" with some
sample data.
- Models, View, Controller

Model Associations
----------------------------------------------
House > belongsTo > City
City > belongsTo > Region
Region > belongsTo > State

City -> hasMany -> Houses
Region -> hasMany -> Cities
State -> hasMany -> Regions.

In the case of "hasMany" relationships, thats where "unbindModel()"
comes in handy. That will limit the results returned in the dataset.
You'll see what I mean when you look at the index action of the
"houses" controller in that zip file. You can try removing the the
calls to "unbindModel()' and notice how that affects the dataset
returned.

Here's what it will look like in your view:

<?php foreach ($houses as $house): ?>
        <strong>House:</strong>  <?php echo $house['House']['title']; ?><br /
>
        <strong>City:</strong> <?php echo $house['City']['city']; ?><br />
        <strong>Region:</strong>  <?php echo $house['City']['Region']
['region']; ?><br />
        <strong>State:</strong> <?php echo $house['City']['Region']['State']
['state']; ?><br /><br />
<?php endforeach; ?>

Hope this helps.

- Dan


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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