DBIx::OODBIx::OO is a database to Perl objects abstraction. | |
Download |
DBIx::OO Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Mihai Bazon
- Publisher web site:
- http://search.cpan.org/~mishoo/DBIx-OO-v0.0.4/lib/DBIx/OO.pm
DBIx::OO Tags
DBIx::OO Description
DBIx::OO is a database to Perl objects abstraction. DBIx::OO is a database to Perl objects abstraction.SYNOPSIS package MyDB; use base 'DBIx::OO'; # We need to overwrite get_dbh since it's an abstract function. # The way you connect to the DB is really your job; this function # should return the database handle. The default get_dbh() croaks. my $dbh; sub get_dbh { $dbh = DBI->connect_cached('dbi:mysql:test', 'user', 'passwd') if !defined $dbh; return $dbh; } package MyDB::Users; use base 'MyDB'; __PACKAGE__->table('Users'); __PACKAGE__->columns(P => , E => ); __PACKAGE__->has_many(pages => 'MyDB::Pages', 'user'); package MyDB::Pages; use base 'MyDB'; __PACKAGE__->table('Pages'); __PACKAGE__->columns(P => , E => ); __PACKAGE__->has_a(user => 'MyDB::Users'); package main; my $u = MyDB::Users->create({ id => 'userid', first_name => 'Q', last_name => 'W' }); my $foo = MyDB::Users->retrieve('userid'); my @p = @{ $foo->fk_pages }; print "User: ", $foo->first_name, " ", $foo->last_name, " pages:n"; foreach (@p) { print $_->title, "n"; } $foo->first_name('John'); $foo->last_name('Doe');# or $foo->set(first_name => 'John', last_name => 'Doe'); $foo->update; Requirements: · Perl
DBIx::OO Related Software