Filewatcher File Search File Search
Content Search
» » » » » DBIx-Simple-Class-0.70.tar.gz » Content »
pkg://DBIx-Simple-Class-0.70.tar.gz:25319/DBIx-Simple-Class-0.70/  info  downloads


DBIx::Simple::Class - Advanced object construction for DBIx::Simple!


You can install this module via CPAN:

    cpan DBIx::Simple::Class

To install manually, run the following commands:

	perl Makefile.PL
	make test
	make install


DBIx::Simple, DBI, DBD::SQLite (for running tests only)


DBIx::Simple::Class is a database table/row abstraction. At the same
time it is not just a fancy representation of a table row like
L<DBIx::Simple::Result::RowObject>. Using this module will make your
code more organized, clean and reliable
(separation of concerns + input-validation).
You will even get some more performance over plain DBIx::Simple
while keeping its' sexy features when you need them. Last but not
least, this module has no other non-CORE dependencies besides
L<DBIx::Simple> and L<DBI>.


  #1. In your class representing a template for a row in a database table or view
  package My::Model::AdminUser;
  use base qw(DBIx::Simple::Class);#this is your base class or a class that extends it

  #sql to be used as table
  sub TABLE { 'users' }  #or: use constant TABLE =>'users';
  sub COLUMNS {[qw(id group_id login_name login_password first_name last_name)]}

  #used to validate params to field-setters
  sub CHECKS{{
    id => { allow => qr/^\d+$/x },
    group_id => { allow => qr/^1$/x, default=>1 },#admin group_id
    login_name => {required => 1, allow => qr/^\p{IsAlnum}{4,12}$/x},
    first_name =>{required => 1, allow => \&avery_complex_check},
    last_name =>{ allow => sub {
        #less complex inline check that modifies the input value
        #see Params::Check::allow and Params::Check::check
  sub WHERE { group_id=> 1} #select only users from admin group
  1;#end of My::Model::AdminUser

  #2. In a start-up script or subroutine
  DBIx::Simple::Class->dbix( DBIx::Simple->connect(...) );

  #3. usage 
  use My::Model::AdminUser;
  my $user = $dbix->select(
    My::Model::AdminUser->TABLE, '*', {login_name => 'fred'}
  #or better (if SQL::Abstract is installed)
  my $user = My::Model::AdminUser->select(login_name => 'fred'); #this is cleaner
  $user->first_name('Fred')->last_name('Flintstone'); #chainable setters
  $user->save; #update row
  my $user = My::Model::AdminUser->new(
    login_name => 'fred',
    first_name => 'Fred',
    last_name =>'Flintstone'
  $user->save();#insert new user
  print "new user has id:".$user->id;
  #select many
  my $class = 'My::Model::AdminUser';
  my @admins = $dbix->select(
  my @admins = $dbix->query(
    $VERY_COMPLEX_SQL, @bind_variables


After installing, you can find documentation for this module with the
perldoc command.

    perldoc DBIx::Simple::Class

You can also look for information at:

    The project wiki

    AnnoCPAN, Annotated CPAN documentation

    CPAN Ratings

    Search CPAN


Copyright (C) 2012 Красимир Беров

This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.

See for more information.

Results 1 - 1 of 1
Help - FTP Sites List - Software Dir.
Search over 15 billion files
© 1997-2017