On Monday, 2 December 2013 19:22:14 UTC+1, Justin Thomas wrote:
>
> I'm using the Tree Behavior in one of my models.  When a new record is 
> added by default it post the new record at the bottom of the tree.  What I 
> need it to do is post the new record at the top of the tree.  
>

That will require updating every existing record in the table.
 

> I've looked at the documentation and I don't see anything to change that 
> default behavior.  
>
 

> I also looked at the reorder method, but I'm unsure how to use that to 
> move a new record to the top of the tree.
>

Reorder is not the method you need - 
moveUp<http://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::moveUp>is.


> If I pass the lft and rght parameters as 1 and 2 will the other records 
> update automatically?  
>

Nope
 

> Any ideas on how to achieve this?
>

Try something =). Alternatively treat the tree inverted - i.e. don't do 
what you're asking but instead query the tree sorted by lft desc - the last 
created record would be first.

AD 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to