I have created the table as show in the example
fields are id, parent_id, lft, rgt, level and name.

Now I am adding the data as following.

my $root = $schema->resultset('Cat')->create({name => 'Cat'});
$root->add_to_children({ name => 'cat1'});

if I call $root->children i get following error.

Schema::Result::Cat::children(): DBI Exception: DBD::mysql::st execute
failed: Table 'sysitm.cat me, cat parent' doesn't exist [for Statement
"SELECT `me`.`id`, `me`.`parent_id`, `me`.`lft`, `me`.`rgt`, `me`.`level`,
`me`.`name` FROM `cat me, cat parent` WHERE ( ( `parent`.`id` = ? AND (
`me`.`parent_id` = ? AND me.lft > parent.lft AND me.rgt < parent.rgt AND
me.level = parent.level + 1 ) ) ) ORDER BY `me`.`lft`" with ParamValues:
0='3', 1='0'] at ./mytest.pl line 31

Basically, what I want is categories and their sub categories there can be
multi level sub categories, see below.

Cat1 -> subcat1->subcat2
------> subcat3 -> subcat4 -> subcat5
Cat2 -> subcat1 -> subcat2 ->subcat3
-------> subcat5 -> subcat6
-------> subcat7

Thanks
On Sat, Dec 18, 2010 at 4:31 PM, David Schmidt <[email protected]> wrote:

> On Sat, Dec 18, 2010 at 7:20 AM, linuxsupport <[email protected]>
> wrote:
> > Hi,
> >
> > Can someone provide me a real example of Tree::NestedSet?
> >
> > Thanks
> >
> > _______________________________________________
> > List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> > IRC: irc.perl.org#dbix-class
> > SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> > Searchable Archive:
> > http://www.grokbase.com/group/[email protected]
> >
>
> Have you tried the example in the documentation? If yes and it failed
> for you perhaps providing the error message would help.
>
> david
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/[email protected]
>
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to