[Dbix-class] DBIx::Class::Tree::NestedSet

linuxsupport lin.support at gmail.com
Sat Dec 18 14:27:17 GMT 2010


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 =3D $schema->resultset('Cat')->create({name =3D> 'Cat'});
$root->add_to_children({ name =3D> '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` =3D ? AND (
`me`.`parent_id` =3D ? AND me.lft > parent.lft AND me.rgt < parent.rgt AND
me.level =3D parent.level + 1 ) ) ) ORDER BY `me`.`lft`" with ParamValues:
0=3D'3', 1=3D'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 <davewood at gmx.at> wrote:

> On Sat, Dec 18, 2010 at 7:20 AM, linuxsupport <lin.support at gmail.com>
> 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/dbix-class@lists.scsys.co.uk
> >
>
> 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/dbix-class@lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20101218/cd4=
0ed61/attachment.htm


More information about the DBIx-Class mailing list