Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    Class::DBI 3.0.17

    Download button

    No screenshots available
    Downloads: 310  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Fair (2.0/5)
    2 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Michael G Schwern | More programs
    Perl Artistic License / FREE
    October 31st, 2007, 05:35 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Class::DBI description

    Class::DBI is a simple database abstraction module.

    Class::DBI is a simple database abstraction module.

    SYNOPSIS

    package Music::DBI;
    use base 'Class::DBI';
    Music::DBI->connection('dbi:mysql:dbname', 'username', 'password');

    package Music::Artist;
    use base 'Music::DBI';
    Music::Artist->table('artist');
    Music::Artist->columns(All => qw/artistid name/);
    Music::Artist->has_many(cds => 'Music::CD');

    package Music::CD;
    use base 'Music::DBI';
    Music::CD->table('cd');
    Music::CD->columns(All => qw/cdid artist title year reldate/);
    Music::CD->has_many(tracks => 'Music::Track');
    Music::CD->has_a(artist => 'Music::Artist');
    Music::CD->has_a(reldate => 'Time::Piece',
    inflate => sub { Time::Piece->strptime(shift, "%Y-%m-%d") },
    deflate => 'ymd',
    );

    Music::CD->might_have(liner_notes => LinerNotes => qw/notes/);

    package Music::Track;
    use base 'Music::DBI';
    Music::Track->table('track');
    Music::Track->columns(All => qw/trackid cd position title/);

    #-- Meanwhile, in a nearby piece of code! --#

    my $artist = Music::Artist->insert({ artistid => 1, name => 'U2' });

    my $cd = $artist->add_to_cds({
    cdid => 1,
    title => 'October',
    year => 1980,
    });

    # Oops, got it wrong.
    $cd->year(1981);
    $cd->update;

    # etc.

    foreach my $track ($cd->tracks) {
    print $track->position, $track->title
    }

    $cd->delete; # also deletes the tracks

    my $cd = Music::CD->retrieve(1);
    my @cds = Music::CD->retrieve_all;
    my @cds = Music::CD->search(year => 1980);
    my @cds = Music::CD->search_like(title => 'October%');

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    database abstraction | database class | Perl module | database | abstraction | Perl

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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