Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    DBIx::OO 0.0.9

    Download button

    No screenshots available
    Downloads: 376  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Mihai Bazon | More programs
    Perl Artistic License / FREE
    January 13th, 2007, 14:05 GMT [view history]
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    DBIx::OO description

    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 => [ 'id' ],
    E => [qw/ first_name last_name email /]);
    __PACKAGE__->has_many(pages => 'MyDB::Pages', 'user');

    package MyDB::Pages;
    use base 'MyDB';

    __PACKAGE__->table('Pages');
    __PACKAGE__->columns(P => [ 'id' ],
    E => [qw/ title content user /]);
    __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;


    Product's homepage

    Requirements:

    · Perl

    What's New in This Release: [ read full changelog ]

    · Fixed bug in search_join_X methods: $#{@$row} no longer works to determine the index of the last element in an array ref, it returns -1 instead. Either it never worked (but AFAIR it did) or it somehow broke in Perl 5.10.

      


    TAGS:

    Perl objects | database abstraction | Perl module | module | database | Perl

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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