Thomas Koch a écrit :
> Hi,
>
> I'm playing with YUI TreeView and the Tree component. The Tree is saved in a
> database with the data fields in the same table as the tree itself:
> id, parent_id, name, some_more_data
>
> Nodes are added via AJAX to the YUI tree everytime a node is opened.
>
> In the moment this results in two database queries for each AJAX request:
> 1. Get the IDs of the nodes
> 2. Get the Data for all the IDs.
>
> I'd like to enhance the component with an
> ezcTreeDbInternalTableDataStore class which can be used for my setup.
> The fetchChildren method of each db backend could then be enhanced with an
> additional parameter to specify, which data fields should be prefetched.
>
> Is this a good idea?
>
>
> Along with this feature request comes the next one: It would be fine, if the
> fetchChildren method could also include the SQL to ask in one query, whether
> a node has children. This information can then be used to use different icons
> in the YUI tree.
>
> Something like this may work:
>
> 'SELECT id, parent_id'
> .implode(',', $data_fields).
> ', subnr'.
> 'FROM indexTable as i,
> (select count(*) from indexTable where parent_id = id) as subnr
> WHERE parent_id = $nodeId'
>
This one looks like it might slow down huge trees a little bit.
Maybe a bit more complex, but you could add a children_count column and
pre-calculate it at node insertion time?
Of course assuming trees are read more often than written to...
>
>
> Have a nice weekend,
>
--
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components