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



Greetings
Gordon


-----Ursprüngliche Nachricht-----
Von: symfony-users@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von 
Peter Van Garderen
Gesendet: Freitag, 11. Mai 2007 01:40
An: symfony-users@googlegroups.com
Betreff: [symfony-users] sfPropelActAsNestedSetBehaviorPlugin -- reload() 
required?


> From: symfony-users@googlegroups.com 
> [mailto:[EMAIL PROTECTED] On Behalf Of Franke Gordon
> Sent: May 9, 2007 12:03 AM
> To: symfony-users@googlegroups.com
> Subject: [symfony-users] AW: [symfony-users] Re: AW: 
> [symfony-users] sfPropelActAsNestedSetBehaviorPlugin
> 
> I insert my yml data via batch and the problem was that i 
> don´t reload() the parent after insert a child so the parent 
> has old left and right values and the next child get not 
> correct left right values ;(
> 
> See test/unit/PropelActAsNestedSetBehaviorTest.php ;)


This may be the cause of similar problems I am having (incorrect left/right
values appearing after a while).

Tristan, is it true that a reload() is required after each
insertion/deletion into the tree? If so, is it the parent node, root node or
both that need to be reloaded?

...and, if so, shouldn't the Wiki & ReadMe documentation be updated to add
the reload() command after each child save() command (see below).

...or better yet, if this is required, why not add the root node reload
automatically in the plugin after any insert/delete/revision of nodes in a
given tree?

--peterVG

-------------------------------------------------
Updated documentation if reload() is required?

=== Simple tree creation ===

<?php
  $root = new ForumPost();
  $root->makeRoot();
  $root->save();

  $p1 = new ForumPost();
  $p1->insertAsFirstChildOf($root);
  $p1->save();
  $root->reload();

  $p2 = new ForumPost();
  $p2->insertAsFirstChildOf($p1);
  $p2->save();
  $root->reload();

  /*
   * Resulting tree :
   *
   * ROOT
   * |- P1
   *    |- P2
   */


=== Multiple trees in a single table ===

<?php
  $root1 = new ForumPost();
  $root1->makeRoot();
  $root1->setTopicId(1);
  $root1->save();

  $root2 = new ForumPost();
  $root2->makeRoot();
  $root2->setTopicId(2);
  $root2->save();

  $p1 = new ForumPost();
  $p1->insertAsFirstChildOf($root1);
  $p1->save();
  $root1->reload();

  $p2 = new ForumPost();
  $p2->insertAsFirstChildOf($root2);
  $p2->save();
  $root2->reload();









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

Reply via email to