nestedset extension bug?

hallo there,

As noob with yii, i try to use the nestedset extension. I created a category table, model, cruds and i am trying to figure out how things should be done. I want to have a hierarhy of categories in my db.

When i try to run my example i get the following error:

TreeBehavior does not have a method named "getIsNewRecord".

Seems that the getIsNewRecord() call is made to the TreeBehaviour that has not this method!

So from stacktrace i see that the call responsible for this is in TreeBehavior.php line 366

361     public function appendChild($node, $brother = null) 

362     {

363         // Fetch nodes information  

364         $parent = $this;

365         $transaction= $this->Owner->dbConnection->beginTransaction();

366         if($this->getIsNewRecord())

i think that one solution is to change line 366 to the following

366         if($this->Owner->getIsNewRecord())

in order to refer to the actual component that has the getIsNewRecord(), instead of refering to the behaviour that doesn’t have it…

hope, this will help some people on the long road for Ithake…

hii, thank you so much. my problem is solved.

the nestedset extenstion really bad documented…

the examples with the “new Root” where root class don’t exists not helpful at all

What is the latest version that I should use?

cause this in comments wroten that not working with 1.1.6

Maybe this one better? ?

This is the latest?

Don’t want to stack myself with buggy version :D

1.05 is the latest one and it’s pretty stable. The one you’ve linked is totally different implementation with some known bugs.

Root there is the name of the model you’ve attached behavior to.

What schema should I chose, if I want to do blog with tree comments ?

the many roots is not what I need because I want to save the roots outside the table

And one root also dont sure if this will do what I want…

I want a blog post to be the root…

And the comments his children

p.s. : you forgot bracket in the example of the behaviour

You’ll need multiple roots since each post comments should be a separate tree and all these should in a single ‘comment’ table.

It will be very hard if I want to use seperate tables? Just trying now to understand whats going on on the behavior…

I want table for posts, and separate table for comments…

I want post row to be root (every row) it will have lft rgt etc…

And why this don’t work ?

$root_id = 1;


my table structure is


-- Table structure for table `tbl_comments`



  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,

  `root` int(10) unsigned DEFAULT NULL,

  `lft` int(10) unsigned NOT NULL,

  `rgt` int(10) unsigned NOT NULL,

  `level` smallint(5) unsigned NOT NULL,

  `title` varchar(255) NOT NULL,

  PRIMARY KEY (`id`),

  KEY `root` (`root`),

  KEY `lft` (`lft`),

  KEY `rgt` (`rgt`),

  KEY `level` (`level`)



-- Dumping data for table `tbl_comments`


INSERT INTO `tbl_comments` (`id`, `root`, `lft`, `rgt`, `level`, `title`) VALUES

(1, 1, 1, 8, 1, 'root1'),

(2, 2, 1, 2, 1, 'root2'),

(3, 1, 4, 5, 2, 'Ford'),

(4, 1, 6, 7, 2, 'Mercedes'),

(5, 1, 2, 3, 2, 'Audi');

of course I dont have root_id column… but I tried to put id there… it gives me error:

CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound. The SQL statement executed was: SELECT * FROM `tbl_comments` `t` WHERE id=? ORDER BY lft 

Yes I know I should some how save for every node the root_id… added the column to the table, I see it don’t update it automatically :(

dckurushin, just to be sure we’re talking about the same extension… which one you’re using?