Hi everyone, Been ripping my hair out on this one, have no idea why it's not working. Hopefully someone here can find something wrong with my code.
I have a model called Regions. There can be main regions, and then there can be subregions that live under the main regions. Each region belongs to a State (another model). Under each region there are Service areas, which is another model. Here is my Regions table: CREATE TABLE IF NOT EXISTS `eco_regions` ( `id` int(11) NOT NULL AUTO_INCREMENT, `created` datetime NOT NULL, `modified` datetime NOT NULL, `user_id` int(11) NOT NULL, `state_id` int(11) NOT NULL, `parent_id` int(11) NOT NULL, `name` varchar(255) NOT NULL, `status` enum('Live','Deleted') NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; When I perform the following in my controller: $regionsResult = $this->Region->find('threaded', array( 'conditions' => array( 'Region.state_id' => $stateID ), 'recursive' => -1 )); I get an array that has all the regions under that $stateID, along with the children regions under each region, etc. However, if I do the following: $regionsResult = $this->Region->find('threaded', array( 'conditions' => array( 'Region.id' => $regionID ), 'recursive' => -1 )); I just get the region record for $regionID, and *no* children, even though all the children regions show up in the previous controller code. I only want to retrieve the children regions under the selected region, and not for the whole state. My models: class Region extends AppModel { var $name = 'Region'; var $order = "Region.name ASC"; var $actsAs = array("Containable"); var $hasMany = array( 'Servicearea' => array( 'className' => 'Servicearea', 'conditions' => '', 'order' => '', 'foreignKey' => 'region_id' ) ); var $belongsTo = array( 'State' => array( 'className' => 'State', 'conditions' => '', 'order' => '', 'foreignKey' => 'state_id' ), 'User' => array( 'className' => 'User', 'conditions' => '', 'order' => '', 'foreignKey' => 'user_id' ) ); } It seems whenever I want to search by Regions.id, *no* children load up, regardless if there's any or not. If I change my conditions to filter by something else, then they all appear! Surely this isn't correct? What am I doing wrong? This is driving me insane. TIA. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---