Yii Framework Forum: nestedset extension bug? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

nestedset extension bug? TreeBehavior does not have a method named "getIsNewRecord". Rate Topic: -----

Poll: nestedset usage (4 member(s) have cast votes)

Is this extension working ?

  1. Don't know (1 votes [25.00%] - View)

    Percentage of vote: 25.00%

  2. Yes, it is! (2 votes [50.00%] - View)

    Percentage of vote: 50.00%

  3. Yes, but needs some customization (1 votes [25.00%] - View)

    Percentage of vote: 25.00%

  4. Yes, but needs a lot of customization (0 votes [0.00%])

    Percentage of vote: 0.00%

  5. Hmm, seems broken (0 votes [0.00%])

    Percentage of vote: 0.00%

  6. Look for something else (0 votes [0.00%])

    Percentage of vote: 0.00%

Vote Guests cannot vote

#1 User is offline   Stratis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 18-February 11

Posted 18 February 2011 - 12:59 PM

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...
0

#2 User is offline   __agus 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 166
  • Joined: 22-April 10
  • Location:Yogyakarta, Indonesia

Posted 01 August 2011 - 01:39 AM

View PostStratis, on 18 February 2011 - 12:59 PM, said:

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.
0

#3 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 06 September 2011 - 02:05 AM

the nestedset extenstion really bad documented...
the examples with the "new Root" where root class don't exists not helpful at all
0

#4 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 06 September 2011 - 04:08 PM

What is the latest version that I should use?
cause this in comments wroten that not working with 1.1.6
http://www.yiiframew...sion/nestedset/

Maybe this one better?
http://code.google.c.../downloads/list
trees_1.0.5.zip ?

This is the latest?
Don't want to stack myself with buggy version :D
0

#5 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,648
  • Joined: 17-January 09
  • Location:Russia

Posted 06 September 2011 - 05:26 PM

1.05 is the latest one and it's pretty stable. The one you've linked is totally different implementation with some known bugs.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#6 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,648
  • Joined: 17-January 09
  • Location:Russia

Posted 06 September 2011 - 05:27 PM

Quote

new Root

Root there is the name of the model you've attached behavior to.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#7 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 07 September 2011 - 04:02 PM

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
0

#8 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,648
  • Joined: 17-January 09
  • Location:Russia

Posted 07 September 2011 - 04:17 PM

You'll need multiple roots since each post comments should be a separate tree and all these should in a single 'comment' table.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#9 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 07 September 2011 - 05:03 PM

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;
Comment::model()->findAll(array('condition'=>'root_id=?','order'=>'lft'),array($root_id));


my table structure is
--
-- Table structure for table `tbl_comments`
--

CREATE TABLE IF NOT EXISTS `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`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

--
-- 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 :(
0

#10 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,648
  • Joined: 17-January 09
  • Location:Russia

Posted 14 September 2011 - 12:14 PM

dckurushin, just to be sure we're talking about the same extension… which one you're using?
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users