DBIx::Custom::Model - Model
use DBIx::Custom::Model;
my $model = DBIx::Custom::Model->new(table => 'books');
dbi
my $dbi = $model->dbi; $model = $model->dbi($dbi);
DBIx::Custom object.
join
my $join = $model->join; $model = $model->join( ['left outer join company on book.company_id = company.id'] );
Join clause, this value is passed to select method.
select
primary_key
my $primary_key = $model->primary_key; $model = $model->primary_key(['id', 'number']);
Primary key,this is passed to insert, update, delete, and select method.
insert
update
delete
table
my $model = $model->table; $model = $model->table('book');
Table name, this is passed to select method.
bind_type
my $type = $model->bind_type; $model = $model->bind_type(['image' => DBI::SQL_BLOB]);
Database data type, this is used as type optioon of insert, update, update_all, delete, delete_all, select, and execute method
update_all
delete_all
execute
DBIx::Custom::Model inherits all methods from Object::Simple, and you can use all methods of DBIx::Custom and DBI and implements the following new ones.
count
my $count = $model->count;
Get rows count.
Options is same as select method's ones.
$model->delete(...);
Same as delete of DBIx::Custom except that you don't have to specify table and primary_key option.
$model->delete_all(...);
Same as delete_all of DBIx::Custom except that you don't have to specify table and primary_key option.
$model->execute(...);
Same as execute of DBIx::Custom except that you don't have to specify table and primary_key option.
$model->insert(...);
Same as insert of DBIx::Custom except that you don't have to specify table and primary_key option.
helper
$model->helper( update_or_insert => sub { my $self = shift; # ... }, find_or_create => sub { my $self = shift; # ... );
Register helper. These helper is called directly from DBIx::Custom::Model object.
$model->update_or_insert; $model->find_or_create;
mycolumn
my $column = $self->mycolumn; my $column = $self->mycolumn(book => ['author', 'title']); my $column = $self->mycolumn(['author', 'title']);
Create column clause for myself. The follwoing column clause is created.
book.author as author, book.title as title
If table name is ommited, table attribute of the model is used. If column names is omitted, columns attribute of the model is used.
columns
new
my $model = DBIx::Custom::Model->new;
Create a DBIx::Custom::Model object.
$model->select(...);
Same as select of DBIx::Custom except that you don't have to specify table, primary_key and jon option.
jon
$model->update(...);
Same as update of DBIx::Custom except that you don't have to specify table and primary_key option.
$model->update_all(param => \%param);
Same as update_all of DBIx::Custom except that you don't have to specify table and primary_key option.
To install DBIx::Custom, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::Custom
CPAN shell
perl -MCPAN -e shell install DBIx::Custom
For more information on module installation, please visit the detailed CPAN module installation guide.