Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    DBIx::Class::Ordered 0.08195

    Download button

    No screenshots available
    Downloads: 378  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.6/5)
    3 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Aran Deltac | More programs
    Perl Artistic License / FREE
    August 6th, 2008, 19:33 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    DBIx::Class::Ordered description

    A Perl module that can be used to modify the position of objects in an ordered list.

    DBIx::Class::Ordered is a Perl module that can be used to modify the position of objects in an ordered list.

    SYNOPSIS

    Create a table for your ordered data.

    CREATE TABLE items (
    item_id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    position INTEGER NOT NULL
    );


    Optionally, add one or more columns to specify groupings, allowing you to maintain independent ordered lists within one table:

    CREATE TABLE items (
    item_id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    position INTEGER NOT NULL,
    group_id INTEGER NOT NULL
    );

    Or even

    CREATE TABLE items (
    item_id INTEGER PRIMARY KEY AUTOINCREMENT,
    name TEXT NOT NULL,
    position INTEGER NOT NULL,
    group_id INTEGER NOT NULL,
    other_group_id INTEGER NOT NULL
    );


    In your Schema or DB class add "Ordered" to the top of the component list.

    __PACKAGE__->load_components(qw( Ordered ... ));

    Specify the column that stores the position number for each row.

    package My::Item;
    __PACKAGE__->position_column('position');


    If you are using one grouping column, specify it as follows:

    __PACKAGE__->grouping_column('group_id');

    Or if you have multiple grouping columns:

    __PACKAGE__->grouping_column(['group_id', 'other_group_id']);

    That's it, now you can change the position of your objects.

    #!/use/bin/perl
    use My::Item;


    my $item = My::Item->create({ name=>'Matt S. Trout' });
    # If using grouping_column:
    my $item = My::Item->create({ name=>'Matt S. Trout', group_id=>1 });

    my $rs = $item->siblings();
    my @siblings = $item->siblings();

    my $sibling;
    $sibling = $item->first_sibling();
    $sibling = $item->last_sibling();
    $sibling = $item->previous_sibling();
    $sibling = $item->next_sibling();

    $item->move_previous();
    $item->move_next();
    $item->move_first();
    $item->move_last();
    $item->move_to( $position );
    $item->move_to_group( 'groupname' );
    $item->move_to_group( 'groupname', $position );
    $item->move_to_group( {group_id=>'groupname', 'other_group_id=>'othergroupname'} );
    $item->move_to_group( {group_id=>'groupname', 'other_group_id=>'othergroupname'}, $position );


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    object position | ordered list | Perl module | object | position | order

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM