Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6949697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:59:25+00:00 2026-05-27T13:59:25+00:00

I’ve read that if you have a model that $actsAs = array(‘Tree’) , that

  • 0

I’ve read that if you have a model that $actsAs = array('Tree'), that you can simply set the parent_id for your seed data, and a call to $this->Model->recover() should generate the proper lft and rght values for you, but when I do this, Cake seems to generate random values every time. The values vary from very large (in the thousands) to negative values. I’ve checked for circular references and found none as well. What could be wrong here?

SQL:

create table menus (
   id        int auto_increment not null,
   parent_id int                null    ,
   lft       int                null    ,
   rght      int                null    ,
   title     varchar(1024)      not null,
   path      varchar(1024)      not null,
   constraint pk_menus primary key (id)
)   ENGINE=InnoDB DEFAULT CHARSET=latin1;

This is the seeded data:          After one Model->recover()
+----+-----------+------+------+  +----+-----------+------+------+
| id | parent_id | lft  | rght |  | id | parent_id | lft  | rght |
+----+-----------+------+------+  +----+-----------+------+------+
|  1 |      NULL | NULL | NULL |  |  1 |      NULL |  595 |  619 |
|  7 |         1 | NULL | NULL |  |  7 |         1 |  619 |  567 |
|  6 |         1 | NULL | NULL |  |  6 |         1 |  627 |  595 |
|  5 |         1 | NULL | NULL |  |  5 |         1 |  600 |  621 |
|  4 |         1 | NULL | NULL |  |  4 |         1 |  603 |  621 |
|  3 |         1 | NULL | NULL |  |  3 |         1 |  619 |  529 |
|  2 |         1 | NULL | NULL |  |  2 |         1 |  595 |  529 |
|  8 |         2 | NULL | NULL |  |  8 |         2 |  627 |  628 |
| 13 |         3 | NULL | NULL |  | 13 |         3 |  595 |  567 |
| 12 |         3 | NULL | NULL |  | 12 |         3 |  627 |  621 |
| 11 |         3 | NULL | NULL |  | 11 |         3 |  595 |  631 |
| 10 |         3 | NULL | NULL |  | 10 |         3 |  604 |  529 |
|  9 |         3 | NULL | NULL |  |  9 |         3 |  595 |  567 |
| 14 |         5 | NULL | NULL |  | 14 |         5 |  628 |  629 |
| 15 |         5 | NULL | NULL |  | 15 |         5 |  567 |  529 |
| 16 |         5 | NULL | NULL |  | 16 |         5 |  619 |  600 |
| 17 |         5 | NULL | NULL |  | 17 |         5 |  627 |  605 |
| 21 |         6 | NULL | NULL |  | 21 |         6 |  567 |  619 |
| 20 |         6 | NULL | NULL |  | 20 |         6 |  595 |  567 |
| 19 |         6 | NULL | NULL |  | 19 |         6 |  619 |  600 |
| 18 |         6 | NULL | NULL |  | 18 |         6 |  567 |  529 |
| 22 |        10 | NULL | NULL |  | 22 |        10 |  567 |  619 |
| 23 |        11 | NULL | NULL |  | 23 |        11 |   64 |  621 |
| 24 |        12 | NULL | NULL |  | 24 |        12 |  627 |  621 |
| 25 |        13 | NULL | NULL |  | 25 |        13 |  605 |  595 |
| 32 |        16 | NULL | NULL |  | 32 |        16 |  628 |  627 |
| 31 |        16 | NULL | NULL |  | 31 |        16 |  567 |  619 |
| 30 |        16 | NULL | NULL |  | 30 |        16 |   64 |  621 |
| 29 |        16 | NULL | NULL |  | 29 |        16 |  567 |  619 |
| 28 |        16 | NULL | NULL |  | 28 |        16 |  595 |  567 |
| 27 |        16 | NULL | NULL |  | 27 |        16 |  627 |  621 |
| 26 |        16 | NULL | NULL |  | 26 |        16 |  605 |  595 |
| 33 |        17 | NULL | NULL |  | 33 |        17 |  567 |  619 |
| 37 |        19 | NULL | NULL |  | 37 |        19 |   52 |  619 |
| 36 |        19 | NULL | NULL |  | 36 |        19 |   52 |  619 |
| 35 |        19 | NULL | NULL |  | 35 |        19 |  595 |  619 |
| 34 |        19 | NULL | NULL |  | 34 |        19 |   63 |  621 |
| 38 |        20 | NULL | NULL |  | 38 |        20 |   63 |  621 |
| 39 |        20 | NULL | NULL |  | 39 |        20 |   63 |  621 |
| 40 |        21 | NULL | NULL |  | 40 |        21 |  605 |  595 |
+----+-----------+------+------+  +----+-----------+------+------+
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:59:26+00:00Added an answer on May 27, 2026 at 1:59 pm

    I found that if I set the lft and rght values of the top level item to 1 and 2 respectively, recover() now generates the rest of the values properly. I find this to be a bug, but not a terrible one.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.