DBIx-Custom icon indicating copy to clipboard operation
DBIx-Custom copied to clipboard

Customizable simple DBI

DBIx::Custom

DBIx::Custom is Perl module to execute insert, update, delete, and select easily.

EXAMPLE

use DBIx::Custom;

Connect

my $dbi = DBIx::Custom->connect( "dbi:mysql:database=dbname", 'ken', '!LFKD%$&', {mysql_enable_utf8 => 1} );

Create model

$dbi->create_model('book');

Insert

$dbi->model('book')->insert({title => 'Perl', author => 'Ken'});

Update

$dbi->model('book')->update({title => 'Perl', author => 'Ken'}, where => {id => 5});

Delete

$dbi->model('book')->delete(where => {author => 'Ken'});

Select

my $result = $dbi->model('book')->select(['title', 'author'], where => {author => 'Ken'});

Select, more complex

select book.title as book.title,

book.author as book.author,

comnapy.name as company.name

form book

left outer join company on book.company_id = company.id

where book.author = ?

order by id limit 0, 5

my $result = $dbi->model('book')->select( [ {book => [qw/title author/]}, {company => ['name']} ], where => {'book.author' => 'Ken'}, join => ['left outer join company on book.company_id = company.id'], append => 'order by id limit 0, 5' );

Get all rows or only one row

my $rows = $result->all; my $row = $result->one;

Execute SQL with named place holder

my $result = $dbi->execute( "select id from book where author = :author and title like :title", {author => 'ken', title => '%Perl%'} );

INSTALLATION

cpan DBIx::Custom

FEATURES

  • Execute insert, update, delete, or select statement easily
  • Create where clause flexibly
  • Named place holder support
  • Model support
  • Connection manager support
  • Choice your favorite relational database management system, MySQL, SQLite, PostgreSQL, Oracle, Microsoft SQL Srver, Microsoft Access, or anything,
  • Filtering by data type or column name
  • Create order by clause flexibly

DOCUMENTS

DBIx::Custom Documents https://github.com/yuki-kimoto/DBIx-Custom/wiki

API reference http://search.cpan.org/~kimoto/DBIx-Custom/

CPAN http://search.cpan.org/~kimoto/DBIx-Custom/lib/DBIx/Custom.pm

WEB SITE

DBIx::Custom - Perl O/R Mapper http://dbix-custom.hateblo.jp/