Class::DBI::AutoIncrement

Class::DBI::AutoIncrement is a Perl module to emulate auto-incrementing columns on Class::DBI subclasses.
Download

Class::DBI::AutoIncrement Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Erwan Lemonnier
  • Publisher web site:
  • http://search.cpan.org/~erwan/Sub-Contract-0.09/lib/Sub/Contract.pm

Class::DBI::AutoIncrement Tags


Class::DBI::AutoIncrement Description

Class::DBI::AutoIncrement is a Perl module to emulate auto-incrementing columns on Class::DBI subclasses. Class::DBI::AutoIncrement is a Perl module to emulate auto-incrementing columns on Class::DBI subclasses.SYNOPSISLet's assume you have a project making use of Class::DBI. You have implemented a subclass of Class::DBI called MyProject::DBI that opens a connection towards your project's database. You also created a class called MyProject::Book that represents the table Book in your database: package MyProject::Book; use base qw(MyProject::DBI); MyProject::Book->table('book'); MyProject::Book->columns(Primary => qw(seqid)); MyProject::Book->table(Others => qw(author title isbn));Now, you would like the column seqid of the table Book to be auto-incrementing, but your database unfortunately does not support auto-incrementing sequences. Instead, use Class::DBI::AutoIncrement to set the value of seqid automagically upon each insert(): package MyProject::Book; use base qw(Class::DBI::AutoIncrement MyProject::DBI); MyProject::Book->table('book'); MyProject::Book->columns(Primary => qw(seqid)); MyProject::Book->table(Others => qw(author title isbn)); MyProject::Book->autoincrement('seqid');From now on, when you call: my $book = Book->insert({author => 'me', title => 'my life'});$book gets its seqid field automagically set to the next available value for that column. If you had 3 rows in the table 'book' having seqids 1, 2 and 3, this new inserted row will get the seqid 4 (assuming a default setup). Requirements: · Perl


Class::DBI::AutoIncrement Related Software