Hello,
On 1/3/07, AD7six <[EMAIL PROTECTED]> wrote:

Hi abing and all,

On Jan 3, 12:50 pm, "Nimrod A. Abing" <[EMAIL PROTECTED]> wrote:
<snip>
> Will this be available on the 1.2 or 1.1 branch or both?

I assume 1.2 only.

Oh well, I might as well port my CMS to 1.2. A lot of the new stuff in
1.2 seems to cover the things that I found lacking in 1.1 that
prompted me to start some modifications to the core CakePHP code.

<snip>
> http://www.sitepoint.com/print/hierarchical-data-database

I maintain that recursion isn't necessary to display MPTT tables.
Anything that is recursive or converts MPTT tables to nested arrays is
not exactly using the benefits that the DB structure offers ;).

You're absolutely right about not requiring recursion. Been looking at
your code as well as the AclNode implementation. But there is one case
I can think of where recursion is necessary. See below.

> For inserts, I am talking about inserting a single new node in an
> arbitrary parent. For example, inserting a new node under Meat, say
> Chicken. I want to insert it so that it goes in between Beef and Pork.
> i.e., We end up with Beef, Chicken, Pork under Meat.

The logic necessary to add a new node in the middle of it's siblings
isn't very different from adding a new node and then reordering. The
minimum executed sql is about the same as creating alone - slightly
different ofsets.

I remember now why I used recursion. I was not able to come up with an
ideal and generic way to compute the offsets for abitrary reordering
and moving. I was in a hurry so I went with the recursive approach.

> For deletes, when I delete a non-leaf node, all of its children will
> be reparented to the immediate parent of their parent.
>
<snip>
> Delete does not seem to work as I expected in the aros example. I get
> the message "aro Daniele (and any child aros) deleted."
>
> This does not conform to my requirement that its child nodes be
> reparented to their grandparent. What I need is akin to a child being
> orphaned and sent to their grandparents when their parents die. Though
> deleting the children of a node makes much more sense when we are
> talking about filesystems.
>

I have never heard of or considered this case. Why would you want to do
that exactly? It seems perfectly logical to me that if you delete a
node you also want to delete it's children. But in any case, the sql to
do what you have explained isn't much different than deleting a node
and all children (would just need to delete the node, re-index the
children -1, the 'new' parent right field -2 and all subsequent nodes
-2.) I just don't understand why you would want to.

This is application-specific. I wanted there to be an option for a
user, if a node is deleted and it contains children, the user should
be able to chose from two options:

A.) Delete everything under the node that is about to be deleted; or

B.) Delete the node, but reassign all children to their grandparent.

Use case A is the most common case. B is for those cases when you want
to just be able to reduce the number of levels in a particular
subtree. This is because reparenting the child nodes of a node one by
one and deleting the empty node takes much more effort (on the part of
the user) than simply deleting the node and reparenting its children
in one go.

<snip>
> Comments are very much welcome. Though at this stage, I am thinking of
> rewriting the whole thing to use the implementation described here:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/461776

Adding redundancy like that will make some tasks simpler but I wouldn't
expect it to help with any of the problems that having large tables
would cause. But variety is what spawns new ideas so if you go that
route I'd be interested to see what you come up with ;).

I most certainly will try it out. But if it falls flat on its face, I
can just use your MPTT code :)
--
_nimrod_a_abing_

[?] http://abing.gotdns.com

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