Hi,

I'm posting this message because i'm a beginner with cakephp, i've
succeeded to make something i wanted to do but i'm wondering if
there's a better way because this one take a lottttttt of time to
achieve.

I'm trying to make a search query on a tree. The search result must
show found items and their children.

At the moment it works like this :


In my model :

function findAllThreaded($root,$conditions = null, $fields = null,
$sort = null,$recursive=null) {
                return $this->__doThread(Model::findAll($conditions, $fields,
$sort,null,null,$recursive), $root);}


In my controller :



$resultitem=$this->Item->findAll($conditions);

 foreach($resultitem as $key=>$result){

$resulttree[$key]['children']=$this->Item-
>findAllThreaded($result["Item"]
["id"],"Item.active='1'",null,'parent_id,Item.id ASC');

}


The way it works is simple : for each found result it retrieves the
result and its children.


The big problem is the following : Some children might have already
been retrieved. (if one of the resultitems is the child of another
one) . As i can get a lot of results, it easily becomes a huge cpu
time consumer..

My question is, is there a way to do this on a more optimized way ?


I'vre thought about :
Making a test on the item level (if the item level in the tree is
higher than a previous one i don't try to retrieve the result >    of
course..it wasn't successful, because there are many branches in the
tree...so i don't really know if the item is in the same branch)

Retrieving the complete tree, then using the interesting branches of
the tree   < my tree is too big . (something like 10.000 results)

Does anybody got an idea ?

Thanks a lot
(Sorry for my bad english)

Stephane.

--~--~---------~--~----~------------~-------~--~----~
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