DBIx::Custom::Model - Model EXPERIMENTAL
use DBIx::Custom::Table;
my $table = DBIx::Custom::Model->new(table => 'books');
dbi
my $dbi = $model->dbi; $model = $model->dbi($dbi);
DBIx::Custom object.
filter
my $dbi = $model->filter $model = $model->filter({out => 'tp_to_date', in => 'date_to_tp'});
This filter is applied when DBIx::Custom's include_model() is called.
include_model()
name
my $name = $model->name; $model = $model->name('book');
Model name.
join
my $join = $model->join; $model = $model->join( ['left outer join company on book.company_id = company.id'] );
Join clause, this is used as select()'s join option.
select()
table
my $table = $model->table; $model = $model->table('book');
Table name, this is used as select() table option. Generally, this is automatically set from class name.
primary_key
my $primary_key = $model->primary_key; $model = $model->primary_key(['id', 'number']);
Foreign key, this is used as primary_key of insert_at,update_at(), delete_at(),select_at().
insert_at
update_at()
delete_at()
select_at()
view
my $view = $model->view; $model = $model->view('select id, DATE(issue_datetime) as date from book');
View. This view is registered by view() of DBIx::Custom when model is included by include_model.
view()
include_model
DBIx::Custom inherits all methods from Object::Simple, and you can use all methods of the object set to dbi. and implements the following new ones.
column
my $column = $self->column(book => ['author', 'title']); my $column = $self->column('book');
Create column clause. The follwoing column clause is created.
book.author as book__author, book.title as book__title
If column names is omitted, columns attribute of the model is used.
columns
delete
$table->delete(...);
Same as delete() of DBIx::Custom except that you don't have to specify table option.
delete()
delete_all
$table->delete_all(...);
Same as delete_all() of DBIx::Custom except that you don't have to specify table option.
delete_all()
delete_at
$table->delete_at(...);
Same as delete() of DBIx::Custom except that you don't have to specify table and primary_key option.
insert
$table->insert(...);
Same as insert() of DBIx::Custom except that you don't have to specify table option.
insert()
$table->insert_at(...);
Same as insert_at() of DBIx::Custom except that you don't have to specify table and primary_key option.
insert_at()
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.
new
my $table = DBIx::Custom::Table->new;
Create a DBIx::Custom::Table object.
select
$table->select(...);
Same as select() of DBIx::Custom except that you don't have to specify table option.
select_at
$table->select_at(...);
Same as select_at() of DBIx::Custom except that you don't have to specify table and primary_key option.
update
$table->update(...);
Same as update() of DBIx::Custom except that you don't have to specify table option.
update()
update_all
$table->update_all(param => \%param);
Same as update_all() of DBIx::Custom except that you don't have to specify table name.
update_all()
update_at
$table->update_at(...);
Same as update_at() 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.