The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
NAME
            Acme::Class::DBI::NoThreats - Simple Database Abstraction

SYNOPSIS
            package Music::DBI;
            use base 'Acme::Class::DBI::NoThreats';
            Music::DBI->set_db('Main', 'dbi:mysql', 'username', 'password');

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

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

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

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

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

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

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

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

            # etc.

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

            $cd->delete; # also deletes the tracks

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

PREFACE
    Acme::Class::DBI::NoThreats is a fork of Class::DBI version 0.96. It is
    identical in every aspect, except for the package name, and that the
    current maintainer agrees NOT TO:

    *   Threaten to sue users who subscribe to the mailing list, or to call
        the police.

    *   threaten to sue users who quote the maintainer's opinions.

    *   threaten to sue users who reconstruct wikis or other materials
        related to this project.

    *   threaten to sue users who post opinions about this module.

    *   threaten to sue users who think things that the maintainer finds
        disagreeable.

    Note that, other than that, THERE ARE NO FURTHER GUARANTEES.
    Specifically, there's no guarantee that the maintainer of the original,
    pre-fork Class::DBI will abide by these terms. There's no guarantee that
    Class::DBI plugins will work. And there's also no guarantee that this
    forked version will be maintained at all! (It's "ACME::", after all.)

DESCRIPTION
    Acme::Class::DBI::NoThreats provides a convenient abstraction layer to a
    database.

    It not only provides a simple database to object mapping layer, but can
    be used to implement several higher order database functions (triggers,
    referential integrity, cascading delete etc.), at the application level,
    rather than at the database.

    This is particularly useful when using a database which doesn't support
    these (such as MySQL), or when you would like your code to be portable
    across multiple databases which might implement these things in
    different ways.

    In short, Acme::Class::DBI::NoThreats aims to make it simple to introduce
    'best practice' when dealing with data stored in a relational database.

PRE-REQUISITES

        Acme::Class::DBI::NoThreats requires on several other modules.
        Installing via the CPAN shell should take care of all these for you.
        But if you need to install by hand you need to have the following:

	To run the module:

 		Class::Accessor          
		Class::Data::Inheritable
		Class::Trigger         
 		Ima::DBI
			(which in turn requires DBI itself, and Class::WhiteHole)

    To test the installation:
       Test::More
       DBD::SQLite
       DBD::mysql
       DBD::Pg