No. I say you must reload a obj when you add a new record to this. The problem is when you not reload the parent you get incorrect values (left and right) The insert use the left and right values from the existing obj to generate new values for the new record.
> Make $root $root (obj: left 1,right: 2; db: left 1,right: 2) > Add $child1 to $root $root (obj: left 1,right: 2; db: left 1,right: 2) $child1 (obj: left 2,right: 3; db: left 2,right: 3) The root entry became a new right value but the $root obj is not updated: $root (obj: left 1,right: 2; db: left 1,right: 4) > Add last child for $root ($child2) the problem is that he use the old $root > values and not the db values $child2 (obj: left 2,right: 3; db: left 4,right: 5) you have a problem so you must reload before you insert $root->reload(); $root (obj: left 1,right: 4; db: left 1,right: 4) $child2 (obj: left 4,right: 5; db: left 4,right: 5) After insert: $root (obj: left 1,right: 4; db: left 1,right: 6) So in every time when you add a child to an existing obj you must only reload the obj that you use in the function not all. Greetings Gordon -----Ursprüngliche Nachricht----- Von: symfony-users@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von Peter Van Garderen Gesendet: Freitag, 11. Mai 2007 19:05 An: symfony-users@googlegroups.com Betreff: [symfony-users] RE: sfPropelActAsNestedSetBehaviorPlugin -- reload() required? Thanks Tristan and Gordon for the response. Please excuse my ignorance but I am afraid that I am still not 100% certain when and where (and why) a node reload is required. Gordon indicated that any time a child is added to a parent, the parent must be reloaded before the add. However, looking at the plugin unit tests, the reloads are done AFTER the add insertions. Also, on lines 115-120 of the plugin unit tests I see that $n2 is added as a new node with $root as its parent (line 116). The parent ($root) is reloaded on line 120 but so is $n1, first on line 119. Why is $n1 also reloaded in this example? Because it is also the child of a node that is getting a new child? Does this mean we have to iterate over and reload all the children of a given node when it gets a new child? What about lines 140-145. Here $n3 is added as a child of $n2. According to Gordon's instructions we should only have to reload $n2 before adding $n3 as its child. However, $n1, $n2 and $root are reloaded AFTER the child insertion. The same goes for lines 172-180 and 213-217. Here every node that was ever added to the tree is reloaded after a child insertion. Is the correct way to do it? Does this mean we have to iterate over and reload ALL the descendents of a root node when any child is inserted? I understand that this is necessary in a pre-order traversal nested tree, I just thought the plugin was doing it for me. Maybe if Tristan can explain why a reload is necessary, i.e. what is it doing, then this could help to eliminate confusion. Cheers, --peterVG > From: symfony-users@googlegroups.com > [mailto:[EMAIL PROTECTED] On Behalf Of Tristan Rivoallan > Sent: May 11, 2007 1:45 AM > To: symfony-users@googlegroups.com > Subject: [symfony-users] AW: [symfony-users] > sfPropelActAsNestedSetBehaviorPlugin -- reload() required? > > indeed, after modifying the tree, it is required to reload nodes that > were already instanciated. > > From: symfony-users@googlegroups.com > [mailto:[EMAIL PROTECTED] On Behalf Of Franke Gordon > Sent: May 10, 2007 11:09 PM > To: symfony-users@googlegroups.com > Subject: [symfony-users] AW: [symfony-users] > sfPropelActAsNestedSetBehaviorPlugin -- reload() required? > > > You must reload the object when you make something like that: > > Make $root > Add $child1 to root > ----------------------- > Add $child11 to $child1 (now you must reload the $child1 before add) > Add $child2 to root (now you must reload the root before add) > ----------------------- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---