DBIx-Custom
view release on metacpan or search on metacpan
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});
lib/DBIx/Custom.pm view on Meta::CPAN
=head1 SYNOPSIS
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});
lib/DBIx/Custom.pm view on Meta::CPAN
book.author as "book-author",
book.title as "book-title"
=head2 connect
# DBI compatible arguments
my $dbi = DBIx::Custom->connect(
"dbi:mysql:database=dbname",
'ken',
'!LFKD%$&',
{mysql_enable_utf8 => 1}
);
# pass DBIx::Custom attributes
my $dbi = DBIx::Custom->connect(
dsn => "dbi:mysql:database=dbname",
user => 'ken',
password => '!LFKD%$&',
option => {mysql_enable_utf8 => 1}
);
Connect to the database and create a new L<DBIx::Custom> object.
L<DBIx::Custom> is a wrapper of L<DBI>.
C<AutoCommit> and C<RaiseError> options are true,
and C<PrintError> option is false by default.
=head2 create_model
lib/DBIx/Custom.pm view on Meta::CPAN
book.author as author,
book.title as title
=head2 new
my $dbi = DBIx::Custom->new(
dsn => "dbi:mysql:database=dbname",
user => 'ken',
password => '!LFKD%$&',
option => {mysql_enable_utf8 => 1}
);
Create a new L<DBIx::Custom> object.
=head2 not_exists
my $not_exists = $dbi->not_exists;
DBIx::Custom::NotExists object, indicating the column is not exists.
This is used in C<param> of L<DBIx::Custom::Where> .
my $dbi = DBIx::Custom->connect(
user => $user,
password => $password,
dsn => "dbi:mysql:dbname=$database"
);
$dbi->connect;
ok(blessed $dbi->dbh);
can_ok($dbi->dbh, qw/prepare/);
ok($dbi->dbh->{AutoCommit});
ok(!$dbi->dbh->{mysql_enable_utf8});
}
{
my $dbi = DBIx::Custom->connect(
user => $user,
password => $password,
dsn => "dbi:mysql:dbname=$database",
option => {AutoCommit => 0, mysql_enable_utf8 => 1}
);
$dbi->connect;
ok(!$dbi->dbh->{AutoCommit});
#ok($dbi->dbh->{mysql_enable_utf8});
}
# fork
{
my $connector = DBIx::Connector->new(
"dbi:mysql:database=$database",
$user,
$password,
DBIx::Custom->new->default_option
);
( run in 0.248 second using v1.01-cache-2.11-cpan-00829025b61 )