GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DBIx::Class::Tree::AdjacencyList::Ordered(3) User Contributed Perl Documentation DBIx::Class::Tree::AdjacencyList::Ordered(3)

DBIx::Class::Tree::AdjacencyList::Ordered - Glue DBIx::Class::Ordered and DBIx::Class::Tree::AdjacencyList together.

Create a table for your tree data.

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

In your Schema or DB class add Tree::AdjacencyList::Ordered to the front of the component list.

  __PACKAGE__->load_components(qw( Tree::AdjacencyList::Ordered ... ));

Specify the column that contains the parent ID and position of each row.

  package My::Employee;
  __PACKAGE__->position_column('position');
  __PACKAGE__->parent_column('parent_id');

This module provides a few extra methods beyond what DBIx::Class::Ordered and DBIx::Class::Tree::AdjacencyList already provide.

  my $parent = $item->parent();
  $item->parent( $parent_obj );
  $item->parent( $parent_id );
  
  my $children_rs = $item->children();
  my @children = $item->children();
  
  $parent->append_child( $child );
  $parent->prepend_child( $child );
  
  $this->attach_before( $that );
  $this->attach_after( $that );

This module provides methods for working with adjacency lists and ordered rows. All of the methods that DBIx::Class::Ordered and DBIx::Class::Tree::AdjacencyList provide are available with this module.

  __PACKAGE__->parent_column('parent_id');

Works the same as AdjacencyList's parent_column() method, but it declares the children() has many relationship to be ordered by the position column.

  my $parent = $item->parent();
  $item->parent( $parent_obj );
  $item->parent( $parent_id );

This method overrides AdjacencyList's parent() method but modifies it so that the object is moved to the last position, then the parent is changed, and then it is moved to the last position of the new list, thus maintaining the intergrity of the ordered lists.

  my $children_rs = $item->children();
  my @children = $item->children();

This method works just like it does in the DBIx::Class::Tree::AdjacencyList module except it orders the children by there position.

  $parent->append_child( $child );

Sets the child to have the specified parent and moves the child to the last position.

  $parent->prepend_child( $child );

Sets the child to have the specified parent and moves the child to the first position.

  $this->attach_before( $that );

Attaches the object at the position just before the calling object's position.

  $this->attach_after( $that );

Attaches the object at the position just after the calling object's position.

  • siblings
  • first_sibling
  • last_sibling
  • previous_sibling
  • next_sibling
  • move_previous
  • move_next
  • move_first
  • move_last
  • move_to
  • insert
  • delete

  • parent_column
  • parent
  • attach_child
  • siblings
  • attach_sibling

  • mk_classdata
  • component_base_class

  • inject_base
  • load_components
  • load_own_components

mk_classaccessor

Aran Clary Deltac <bluefeet@cpan.org>

You may distribute this code under the same terms as Perl itself.
2011-01-03 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.