FAQ
I have 3 tables, users, user_cat, and cat, table structure and relationship
are setup as follows.

User.pm

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"username",
{ data_type => "text", is_nullable => 1 },
"password",
{ data_type => "text", is_nullable => 1 },
"email_address",
{ data_type => "text", is_nullable => 1 },
"first_name",
{ data_type => "text", is_nullable => 1 },
"last_name",
{ data_type => "text", is_nullable => 1 },
"active",
{ data_type => "integer", is_nullable => 1 },
);
__PACKAGE__->set_primary_key("
id");

__PACKAGE__->has_many("usercats", "Example::Schema::Result::UserCat",{
"foreign.user_id" => "self.id" },);
__PACKAGE__->many_to_many(cats => 'usercats', 'cat');

UserCat.pm

__PACKAGE__->add_columns(
"user_id",
{ data_type => "integer", is_nullable => 0 },
"cat_id",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
);
__PACKAGE__->set_primary_key("user_id", "cat_id");

__PACKAGE__->belongs_to("user", "Example::Schema::Result::User", { id =>
"user_id" },{ join_type => "LEFT" },);
__PACKAGE__->belongs_to("cat", "Example::Schema::Result::Cat", { id =>
"cat_id" },{ join_type => "LEFT" },);

Cat.pm

__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"cat_name",
{ data_type => "text", is_nullable => 0 },
"parent_id",
{ data_type => "integer", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id","parent_id");

__PACKAGE__->has_many("usercat","Example::Schema::Result::UserCat",{
"foreign.cat_id" => "self.id" },);
__PACKAGE__>many_to_many("allcat", "usercat', "cat");

I am able to retrieve all users in any particular category using "allcat"
many_to_many relationship.

In cat table I have both category and sub category, if a row have parent_id
0 then it is sub category.
How can I get all users belong to one category and its sub categories?

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101209/de7dc364/attachment.htm

Search Discussions

  • David Schmidt at Dec 9, 2010 at 8:55 am

    On Thu, Dec 9, 2010 at 9:37 AM, linuxsupport wrote:
    I have 3 tables, users, user_cat, and cat, table structure and relationship
    are setup as follows.

    User.pm

    __PACKAGE__->add_columns(
    ? "id",
    ? { data_type => "integer", is_nullable => 0 },
    ? "username",
    ? { data_type => "text", is_nullable => 1 },
    ? "password",
    ? { data_type => "text", is_nullable => 1 },
    ? "email_address",
    ? { data_type => "text", is_nullable => 1 },
    ? "first_name",
    ? { data_type => "text", is_nullable => 1 },
    ? "last_name",
    ? { data_type => "text", is_nullable => 1 },
    ? "active",
    ? { data_type => "integer", is_nullable => 1 },
    );
    __PACKAGE__->set_primary_key("
    id");

    __PACKAGE__->has_many("usercats", "Example::Schema::Result::UserCat",{
    "foreign.user_id" => "self.id" },);
    __PACKAGE__->many_to_many(cats => 'usercats', 'cat');

    UserCat.pm

    __PACKAGE__->add_columns(
    ? "user_id",
    ? { data_type => "integer", is_nullable => 0 },
    ? "cat_id",
    ? { data_type => "integer", default_value => 0, is_nullable => 0 },
    );
    __PACKAGE__->set_primary_key("user_id", "cat_id");

    __PACKAGE__->belongs_to("user", "Example::Schema::Result::User", { id =>
    "user_id" },{ join_type => "LEFT" },);
    __PACKAGE__->belongs_to("cat", "Example::Schema::Result::Cat", { id =>
    "cat_id" },{ join_type => "LEFT" },);

    Cat.pm

    __PACKAGE__->add_columns(
    ? "id",
    ? { data_type => "integer", is_nullable => 0 },
    ? "cat_name",
    ? { data_type => "text", is_nullable => 0 },
    ?"parent_id",
    ? { data_type => "integer", is_nullable => 0 },
    );
    __PACKAGE__->set_primary_key("id","parent_id");

    __PACKAGE__->has_many("usercat","Example::Schema::Result::UserCat",{
    "foreign.cat_id" => "self.id" },);
    __PACKAGE__>many_to_many("allcat", "usercat', "cat");

    I am able to retrieve all users in any particular category using "allcat"
    many_to_many relationship.

    In cat table I have both category and sub category, if a row have parent_id
    0 then it is sub category.
    How can I get all users belong to one category and its sub categories?

    Thanks in advance.


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    That's entirely a DBIx::Class question. You might want to ask in
    #dbix-class on irc.perl.org or at the DBIx::Class mailinglist
    http://lists.scsys.co.uk/mailman/listinfo/dbix-class

    david
  • Emmanuel Otton at Dec 10, 2010 at 9:11 am

    Le 09/12/2010 09:37, linuxsupport a écrit :
    I have 3 tables, users, user_cat, and cat, table structure and
    relationship are setup as follows.
    User.pm
    __PACKAGE__->add_columns(
    "id", { data_type => "integer", is_nullable => 0 },
    "username",{ data_type => "text", is_nullable => 1 },
    "password", { data_type => "text", is_nullable => 1 },
    "email_address", { data_type => "text", is_nullable => 1 },
    "first_name", { data_type => "text", is_nullable => 1 },
    "last_name", { data_type => "text", is_nullable => 1 },
    "active", { data_type => "integer", is_nullable => 1 },
    );
    __PACKAGE__->set_primary_key("id");
    __PACKAGE__->has_many("usercats", "Example::Schema::Result::UserCat",{
    "foreign.user_id" => "self.id <http://self.id/>" },);
    __PACKAGE__->many_to_many(cats => 'usercats', 'cat');

    UserCat.pm
    __PACKAGE__->add_columns(
    "user_id", { data_type => "integer", is_nullable => 0 },
    "cat_id", { data_type => "integer", default_value => 0, is_nullable
    => 0 },
    );
    __PACKAGE__->set_primary_key("user_id", "cat_id");
    __PACKAGE__->belongs_to("user", "Example::Schema::Result::User", { id
    => "user_id" },{ join_type => "LEFT" },);
    __PACKAGE__->belongs_to("cat", "Example::Schema::Result::Cat", { id =>
    "cat_id" },{ join_type => "LEFT" },);

    Cat.pm
    __PACKAGE__->add_columns(
    "id", { data_type => "integer", is_nullable => 0 },
    "cat_name", { data_type => "text", is_nullable => 0 },
    "parent_id", { data_type => "integer", is_nullable => 0 },
    );
    __PACKAGE__->set_primary_key("id","parent_id");
    __PACKAGE__->has_many("usercat","Example::Schema::Result::UserCat",{
    "foreign.cat_id" => "self.id <http://self.id/>" },);
    __PACKAGE__>many_to_many("allcat", "usercat', "cat");

    I am able to retrieve all users in any particular category using
    "allcat" many_to_many relationship.
    Are you, really ?
    The navigation path you indicate in your "allcat" many_to_many
    relationship does not seem to lead from Cat to Users but from Cat to Cat
    itself, which seems of no practical use.

    I rather would have written:
    __PACKAGE__->many_to_many("users","usercat","user");

    So that I can get the users in any category this way:
    my $cat = $schema->resultset("Cat)->find($my_cat_id);
    my @users_belonging_directly_to_that_category = $cat->users;
    In cat table I have both category and sub category, if a row have
    parent_id > 0 then it is sub category.
    How can I get all users belong to one category and its sub categories?
    Now to get recursively all users belonging to this category AND all
    sub-categories is another problem.

    The procedural/Perlish/DBIx::Classish solution would be:
    # first, add to Cat.pm an accessor to the sub-categories
    __PACKAGE__->has_many("subcats",""Example::Schema::Result::Cat",{
    "foreign.parent_id" => "self.id <http://self.id/>" });

    # then, in your program:
    my $cat = $schema->resultset("Cat)->find($my_cat_id);
    my @users_belonging_to_that_category_and_its_subcats = $cat->users;

    my @subcats = $cat->subcats;
    for my $subcat (@subcats)
    push @users_belonging_to_that_category_and_its_subcats , $cat->users;
    }
    # assuming the reflexive relationship is one level only
    # i.e. no sub-sub-..etc..-categories


    A (better in my -humble- opinion) solution would be more SQL-oriented
    (after all, isn't the declarative SQL way the reason why we all use
    RDBMSes ?)

    First of all, create a view giving what you want:

    create view users_by_cat_and_subcats as
    select cat.id cat_id, user.*
    from cat join usercat on usercat.cat_id = cat.id
    join user on user.id = usercat.user_id
    union select parent.cat.id cat_id , user.*
    from cat parent_cat join cat child_cat on child_cat.parent_id =
    parent_cat.cat_id
    join usercat on usercat.cat_id = child_cat.id
    join user on user.id = usercat.user_id ;

    Then create (automatically, by make_schema_at) a UsersByCatAndSubcat.pm
    to map this table to a DBIx::Class and just use it:
    my @users_belonging_to_that_category_and_its_subcats =
    $schema->resultset('UsersByCatAndSubcat')->search( { cat_id =>
    $my_category } )->all;

    It's always difficult to use the right tool, and I've seen ugly things
    like simple left joins replaced by 15 lines of while, if defined,
    push,etc...
    RDBMSes have dominated our domain for nearly forty years for a reason,
    which is the expressive power of SQL, itself based on strong theoretical
    mathematical background.
    My advice is: don't forget you have a RDBMS, and thus the full power of
    SQL, at your disposal.

    Sorry for this answer to a slightly off-catalyst-topic question; I will
    subscribe to the DBIx::Class list right away.

    --
    Emmanuel Otton - Ecole des mines d'Albi-Carmaux - département informatique - Tél: 05 63 49 30 86

    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101210/4b80406f/attachment.htm
  • Linuxsupport at Dec 16, 2010 at 9:40 am
    Thanks, it worked.

    But how to do it If I have sub categories of sub category?

    Example is below.

    id name parent _id
    1 cat1 0
    2 cat2 1
    3 cat3 0
    4 cat4 2
    5 cat5 4

    Here, I have cat1 > cat2 -> cat4 > cat5, there may be sub categories of any
    of sub category.

    Thanks
    On Fri, Dec 10, 2010 at 9:12 AM, Emmanuel Otton wrote:

    Le 09/12/2010 09:37, linuxsupport a écrit :

    I have 3 tables, users, user_cat, and cat, table structure and relationship
    are setup as follows.
    User.pm
    __PACKAGE__->add_columns(
    "id", { data_type => "integer", is_nullable => 0 },
    "username",{ data_type => "text", is_nullable => 1 },
    "password", { data_type => "text", is_nullable => 1 },
    "email_address", { data_type => "text", is_nullable => 1 },
    "first_name", { data_type => "text", is_nullable => 1 },
    "last_name", { data_type => "text", is_nullable => 1 },
    "active", { data_type => "integer", is_nullable => 1 },
    );
    __PACKAGE__->set_primary_key("id");
    __PACKAGE__->has_many("usercats", "Example::Schema::Result::UserCat",{
    "foreign.user_id" => "self.id" },);
    __PACKAGE__->many_to_many(cats => 'usercats', 'cat');

    UserCat.pm
    __PACKAGE__->add_columns(
    "user_id", { data_type => "integer", is_nullable => 0 },
    "cat_id", { data_type => "integer", default_value => 0, is_nullable => 0
    },
    );
    __PACKAGE__->set_primary_key("user_id", "cat_id");
    __PACKAGE__->belongs_to("user", "Example::Schema::Result::User", { id =>
    "user_id" },{ join_type => "LEFT" },);
    __PACKAGE__->belongs_to("cat", "Example::Schema::Result::Cat", { id =>
    "cat_id" },{ join_type => "LEFT" },);

    Cat.pm
    __PACKAGE__->add_columns(
    "id", { data_type => "integer", is_nullable => 0 },
    "cat_name", { data_type => "text", is_nullable => 0 },
    "parent_id", { data_type => "integer", is_nullable => 0 },
    );
    __PACKAGE__->set_primary_key("id","parent_id");
    __PACKAGE__->has_many("usercat","Example::Schema::Result::UserCat",{
    "foreign.cat_id" => "self.id" },);
    __PACKAGE__>many_to_many("allcat", "usercat', "cat");

    I am able to retrieve all users in any particular category using "allcat"
    many_to_many relationship.

    Are you, really ?
    The navigation path you indicate in your "allcat" many_to_many relationship
    does not seem to lead from Cat to Users but from Cat to Cat itself, which
    seems of no practical use.

    I rather would have written:
    __PACKAGE__->many_to_many("users","usercat","user");

    So that I can get the users in any category this way:
    my $cat = $schema->resultset("Cat)->find($my_cat_id);
    my @users_belonging_directly_to_that_category = $cat->users;


    In cat table I have both category and sub category, if a row have
    parent_id > 0 then it is sub category.
    How can I get all users belong to one category and its sub categories?

    Now to get recursively all users belonging to this category AND all
    sub-categories is another problem.

    The procedural/Perlish/DBIx::Classish solution would be:
    # first, add to Cat.pm an accessor to the sub-categories
    __PACKAGE__->has_many("subcats",""Example::Schema::Result::Cat",{
    "foreign.parent_id" => "self.id" });

    # then, in your program:
    my $cat = $schema->resultset("Cat)->find($my_cat_id);
    my @users_belonging_to_that_category_and_its_subcats = $cat->users;

    my @subcats = $cat->subcats;
    for my $subcat (@subcats)
    push @users_belonging_to_that_category_and_its_subcats , $cat->users;
    }
    # assuming the reflexive relationship is one level only
    # i.e. no sub-sub-..etc..-categories


    A (better in my -humble- opinion) solution would be more SQL-oriented
    (after all, isn't the declarative SQL way the reason why we all use RDBMSes
    ?)

    First of all, create a view giving what you want:

    create view users_by_cat_and_subcats as
    select cat.id cat_id, user.*
    from cat join usercat on usercat.cat_id = cat.id
    join user on user.id = usercat.user_id
    union select parent.cat.id cat_id , user.*
    from cat parent_cat join cat child_cat on child_cat.parent_id =
    parent_cat.cat_id
    join usercat on usercat.cat_id = child_cat.id
    join user on user.id = usercat.user_id ;

    Then create (automatically, by make_schema_at) a UsersByCatAndSubcat.pm to
    map this table to a DBIx::Class and just use it:
    my @users_belonging_to_that_category_and_its_subcats =
    $schema->resultset('UsersByCatAndSubcat')->search( { cat_id =>
    $my_category } )->all;

    It's always difficult to use the right tool, and I've seen ugly things like
    simple left joins replaced by 15 lines of while, if defined, push,etc...
    RDBMSes have dominated our domain for nearly forty years for a reason,
    which is the expressive power of SQL, itself based on strong theoretical
    mathematical background.
    My advice is: don't forget you have a RDBMS, and thus the full power of
    SQL, at your disposal.

    Sorry for this answer to a slightly off-catalyst-topic question; I will
    subscribe to the DBIx::Class list right away.

    --
    Emmanuel Otton - Ecole des mines d'Albi-Carmaux - département informatique - Tél: 05 63 49 30 86


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101216/8497c79e/attachment.htm
  • Hauck, William B. at Dec 16, 2010 at 4:15 pm
    Not sure how to do it in a DBIC-like fashion, but these few links show you how to do it in SQL for PostgreSQL and MySQL. Oracle and DB2 have hierarchical functionality built-in.

    http://www.postgresql.org/docs/8.4/static/queries-with.html

    http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

    http://onlamp.com/lpt/a/5007


    On 12/16/10 4:40 AM, "linuxsupport" wrote:

    Thanks, it worked.

    But how to do it If I have sub categories of sub category?

    Example is below.

    id name parent _id
    1 cat1 0
    2 cat2 1
    3 cat3 0
    4 cat4 2
    5 cat5 4

    Here, I have cat1 > cat2 -> cat4 > cat5, there may be sub categories of any of sub category.

    Thanks

    On Fri, Dec 10, 2010 at 9:12 AM, Emmanuel Otton wrote:

    Le 09/12/2010 09:37, linuxsupport a ?crit :
    I have 3 tables, users, user_cat, and cat, table structure and relationship are setup as follows.
    User.pm
    __PACKAGE__->add_columns(
    "id", { data_type => "integer", is_nullable => 0 },
    "username",{ data_type => "text", is_nullable => 1 },
    "password", { data_type => "text", is_nullable => 1 },
    "email_address", { data_type => "text", is_nullable => 1 },
    "first_name", { data_type => "text", is_nullable => 1 },
    "last_name", { data_type => "text", is_nullable => 1 },
    "active", { data_type => "integer", is_nullable => 1 },
    );
    __PACKAGE__->set_primary_key("id");

    __PACKAGE__->has_many("usercats", "Example::Schema::Result::UserCat",{ "foreign.user_id" => "self.id <http://self.id/> " },);
    __PACKAGE__->many_to_many(cats => 'usercats', 'cat');

    UserCat.pm
    __PACKAGE__->add_columns(
    "user_id", { data_type => "integer", is_nullable => 0 },
    "cat_id", { data_type => "integer", default_value => 0, is_nullable => 0 },
    );
    __PACKAGE__->set_primary_key("user_id", "cat_id");
    __PACKAGE__->belongs_to("user", "Example::Schema::Result::User", { id => "user_id" },{ join_type => "LEFT" },);
    __PACKAGE__->belongs_to("cat", "Example::Schema::Result::Cat", { id => "cat_id" },{ join_type => "LEFT" },);

    Cat.pm
    __PACKAGE__->add_columns(
    "id", { data_type => "integer", is_nullable => 0 },
    "cat_name", { data_type => "text", is_nullable => 0 },
    "parent_id", { data_type => "integer", is_nullable => 0 },
    );
    __PACKAGE__->set_primary_key("id","parent_id");
    __PACKAGE__->has_many("usercat","Example::Schema::Result::UserCat",{ "foreign.cat_id" => "self.id <http://self.id/> " },);
    __PACKAGE__>many_to_many("allcat", "usercat', "cat");

    I am able to retrieve all users in any particular category using "allcat" many_to_many relationship.


    Are you, really ?
    The navigation path you indicate in your "allcat" many_to_many relationship does not seem to lead from Cat to Users but from Cat to Cat itself, which seems of no practical use.

    I rather would have written:
    __PACKAGE__->many_to_many("users","usercat","user");

    So that I can get the users in any category this way:
    my $cat = $schema->resultset("Cat)->find($my_cat_id);
    my @users_belonging_directly_to_that_category = $cat->users;




    In cat table I have both category and sub category, if a row have parent_id > 0 then it is sub category.
    How can I get all users belong to one category and its sub categories?

    Now to get recursively all users belonging to this category AND all sub-categories is another problem.

    The procedural/Perlish/DBIx::Classish solution would be:
    # first, add to Cat.pm an accessor to the sub-categories
    __PACKAGE__->has_many("subcats",""Example::Schema::Result::Cat",{ "foreign.parent_id" => "self.id <http://self.id/> " });

    # then, in your program:
    my $cat = $schema->resultset("Cat)->find($my_cat_id);
    my @users_belonging_to_that_category_and_its_subcats = $cat->users;

    my @subcats = $cat->subcats;
    for my $subcat (@subcats)
    push @users_belonging_to_that_category_and_its_subcats , $cat->users;
    }
    # assuming the reflexive relationship is one level only
    # i.e. no sub-sub-..etc..-categories


    A (better in my -humble- opinion) solution would be more SQL-oriented (after all, isn't the declarative SQL way the reason why we all use RDBMSes ?)

    First of all, create a view giving what you want:

    create view users_by_cat_and_subcats as
    select cat.id <http://cat.id> cat_id, user.*
    from cat join usercat on usercat.cat_id = cat.id <http://cat.id>
    join user on user.id <http://user.id> = usercat.user_id
    union select parent.cat.id <http://parent.cat.id> cat_id , user.*
    from cat parent_cat join cat child_cat on child_cat.parent_id = parent_cat.cat_id
    join usercat on usercat.cat_id = child_cat.id <http://child_cat.id>
    join user on user.id <http://user.id> = usercat.user_id ;

    Then create (automatically, by make_schema_at) a UsersByCatAndSubcat.pm to map this table to a DBIx::Class and just use it:
    my @users_belonging_to_that_category_and_its_subcats =
    $schema->resultset('UsersByCatAndSubcat')->search( { cat_id => $my_category } )->all;

    It's always difficult to use the right tool, and I've seen ugly things like simple left joins replaced by 15 lines of while, if defined, push,etc...
    RDBMSes have dominated our domain for nearly forty years for a reason, which is the expressive power of SQL, itself based on strong theoretical mathematical background.
    My advice is: don't forget you have a RDBMS, and thus the full power of SQL, at your disposal.

    Sorry for this answer to a slightly off-catalyst-topic question; I will subscribe to the DBIx::Class list right away.


    CONFIDENTIALITY NOTICE: This E-Mail is intended only for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you have received this communication in error, please do not distribute and delete the original message. Please notify the sender by E-Mail at the address shown. Thank you for your compliance
  • Charlie Garrison at Dec 16, 2010 at 11:36 pm
    Good morning,

    On 16/12/10 at 11:15 AM -0500, Hauck, William B.
    wrote:
    Not sure how to do it in a DBIC-like fashion, but these few
    links show you how to do it in SQL for PostgreSQL and MySQL.
    Oracle and DB2 have hierarchical functionality built-in.

    http://www.postgresql.org/docs/8.4/static/queries-with.html

    http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

    http://onlamp.com/lpt/a/5007
    I haven't been following this thread closely, but I think one of
    the DBIC::Tree modules is what OP is looking for:

    <http://search.cpan.org/perldoc?DBIx::Class::Tree::AdjacencyList>
    <http://search.cpan.org/perldoc?DBIx::Class::Tree::NestedSet>


    Charlie

    --
    ? Charlie Garrison ? <garrison@zeta.org.au>

    O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
    ? http://www.ietf.org/rfc/rfc1855.txt
  • Will Trillich at Dec 17, 2010 at 2:52 pm
    </lurk>

    Ooh, I didn't know about either of those. Very, very sweet! And one for
    nested-sets and another for parent-links/adjacency lists.

    This is what's so great about open source mailing lists -- the serendipity.
    Here on a Catalyst web-framework list you learn cool, tangential things
    about DBIC that you didn't know you were missing, and then you can just go
    nab new tools that make life easy!

    Awesome.

    On Thu, Dec 16, 2010 at 11:36 PM, Charlie Garrison wrote:

    Good morning,


    On 16/12/10 at 11:15 AM -0500, Hauck, William B. wrote:

    Not sure how to do it in a DBIC-like fashion, but these few links show you
    I haven't been following this thread closely, but I think one of the
    DBIC::Tree modules is what OP is looking for:

    <http://search.cpan.org/perldoc?DBIx::Class::Tree::AdjacencyList>
    <http://search.cpan.org/perldoc?DBIx::Class::Tree::NestedSet>


    Charlie

    --
    � Charlie Garrison ♊ <garrison@zeta.org.au>

    O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
    〠 http://www.ietf.org/rfc/rfc1855.txt


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/


    --
    Failure is not important. How you overcome it, is.
    -- Nick Vujicic
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101217/19b6b3d4/attachment.htm
  • Linuxsupport at Dec 17, 2010 at 8:17 pm
    OK, I switched to Tree::NestedSet.

    Can someone give me real example, its not working for me.

    Thanks

    On Fri, Dec 17, 2010 at 8:22 PM, will trillich
    wrote:
    </lurk>

    Ooh, I didn't know about either of those. Very, very sweet! And one for
    nested-sets and another for parent-links/adjacency lists.

    This is what's so great about open source mailing lists -- the serendipity.
    Here on a Catalyst web-framework list you learn cool, tangential things
    about DBIC that you didn't know you were missing, and then you can just go
    nab new tools that make life easy!

    Awesome.

    On Thu, Dec 16, 2010 at 11:36 PM, Charlie Garrison wrote:

    Good morning,


    On 16/12/10 at 11:15 AM -0500, Hauck, William B. <William.Hauck@ibx.com>
    wrote:

    Not sure how to do it in a DBIC-like fashion, but these few links show
    you how to do it in SQL for PostgreSQL and MySQL. Oracle and DB2 have
    hierarchical functionality built-in.

    http://www.postgresql.org/docs/8.4/static/queries-with.html

    http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

    http://onlamp.com/lpt/a/5007
    I haven't been following this thread closely, but I think one of the
    DBIC::Tree modules is what OP is looking for:

    <http://search.cpan.org/perldoc?DBIx::Class::Tree::AdjacencyList>
    <http://search.cpan.org/perldoc?DBIx::Class::Tree::NestedSet>


    Charlie

    --
    � Charlie Garrison ♊ <garrison@zeta.org.au>

    O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
    〠 http://www.ietf.org/rfc/rfc1855.txt


    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/


    --
    Failure is not important. How you overcome it, is.
    -- Nick Vujicic

    _______________________________________________
    List: Catalyst@lists.scsys.co.uk
    Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
    Searchable archive:
    http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
    Dev site: http://dev.catalyst.perl.org/
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20101218/a564a088/attachment.htm
  • Charlie Garrison at Dec 18, 2010 at 4:25 am
    Good afternoon,

    On 18/12/10 at 1:47 AM +0530, linuxsupport
    wrote:
    OK, I switched to Tree::NestedSet.

    Can someone give me real example, its not working for me.
    Can I suggest you move this to the DBIx::Class mailing list. I
    expect you'll get more responses there. And show what you're
    trying that's not working, otherwise look at the tests for real examples.


    Charlie

    --
    ? Charlie Garrison ? <garrison@zeta.org.au>

    O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
    ? http://www.ietf.org/rfc/rfc1855.txt

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedDec 9, '10 at 8:37a
activeDec 18, '10 at 4:25a
posts9
users6
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase