package DBIx::Custom::MySQL; use strict; use warnings; use base 'DBIx::Custom'; __PACKAGE__->attr([qw/database host port/]); sub connect { my $proto = shift; # Create a new object my $self = ref $proto ? $proto : $proto->new(@_); # Data source if (!$self->data_source) { my $database = $self->database; my $host = $self->host; my $port = $self->port; my $data_source = "dbi:mysql:"; $data_source .= "database=$database;" if $database; $data_source .= "host=$host;" if $host; $data_source .= "port=$port;" if $port; $self->data_source($data_source); } return $self->SUPER::connect; } sub last_insert_id { shift->dbh->{mysql_insertid} } 1; =head1 NAME DBIx::Custom::MySQL - MySQL implementation =head1 SYNOPSYS # Connect to the database my $dbi = DBIx::Custom::MySQL->connect( user => 'taro', password => 'kliej&@K', database => 'dbname' ); # Get last insert id my $last_insert_id = $dbi->last_insert_id; =head1 ATTRIBUTES L inherits all attributes from L and implements the following new ones. =head2 C my $database = $dbi->database; $dbi = $dbi->database('dbname'); Database name. C method use this value to connect the database if C is not specified. =head2 C my $host = $dbi->host; $dbi = $dbi->host('somehost'); Host name or IP address. C method use this value to connect the database if C is not specified. =head2 C my $port = $dbi->port; $dbi = $dbi->port(1198); Port number. C method use this value to connect the database if C is not specified. =head1 METHODS L inherits all methods from L and implements the following new ones. =head2 C my $dbi = DBIx::Custom::MySQL->connect( user => 'taro', password => 'kliej&@K', database => 'dbname', host => 'somehost', port => 2000 ); Create a new L object and connect to the database. This method overrides C method. You can specify all attributes of L and L, such as C, C, C. =head2 C my $last_insert_id = $dbi->last_insert_id; Get last insert id. This is same as C function in MySQL. =cut