NAME
Class::DBI::Relationship::HasManyOrdered - A Class::DBI module for Ordered 'Has Many' relationships
SYNOPSIS
In your classes:
package ContentManager::DBI;
use base 'Class::DBI';
Music::DBI->connection('dbi:mysql:dbname', 'username', 'password');
__PACKAGE__->add_relationship_type(has_many_ordered => 'Class::DBI::Relationship::IsA');
...
package ContentManager::Image;
use base 'ContentManager::DBI';
ContentManager::Image->table('images');
ContentManager::Image->columns(All => qw/image_id name position filename/);
...
package ContentManager::Page;
use base 'ContentManager::DBI';
ContentManager::Page->table('pages');
ContentManager::Page->columns(All => qw/page_id title date_to_publish date_to_archive/);
Page->has_a(category => Category);
Page->has_many(authors => Authors);
Page->has_many_ordered(paragraphs => Paragraphs => {sort => 'position', map => 'PageParagraphs'});
Page->has_many_ordered(images => Images => {sort => 'position', map => 'PageImages'});
In your application ...
use ContentManager::Page;
my $page = ContentManager::Page->create( {title=>'Extending Class::DBI', date_to_publish=>'dd/mm/yyyy'});
my $image1 = Image->search(name=>'Class::DBI logo');
my @figures = Image->search(name=>'Class Diagram (CDBI)', order_by => 'filename');
my $author_image = Image->search(name=>'Aaron Trevena - portrait');
$page->insert_Images(@figures); # inserts figures into next/last available positions, sets positions
...
$page->prepend_Images($image1); # inserts image into first position, resets other image positions
$page->append_Images($author_image); # appends image to last position
...
$page->update();
DESCRIPTION
Class::DBI::Relationship::HasManyOrdered Provides an ordered 'Has Many' relationship between Class::DBI classes. This relationship enhances the HasMany relationship already provided in Class::DBI to allow you to quickly and easily deal with ordered 'One to Many' or 'Many to Many' relationships without additional handcoding while preserving as much of the original behaviour and syntax as possible.
For more information See Class::DBI and Class::DBI::Relationship.
EXPORT
None.
SEE ALSO
AUTHOR
Aaron Trevena, <teejay@droogs.org>
Based on Class::DBI::Relationship::HasMany.
COPYRIGHT AND LICENSE
Copyright (C) 2004 by Aaron Trevena
Class::DBI::Relationship::HasMany code, etc Copyright (C) its respective authors.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.1 or, at your option, any later version of Perl 5 you may have available.