DBIx::Custom::Model - Model (experimental)
use DBIx::Custom::Table;
my $table = DBIx::Custom::Model->new(table => 'books');
columns
my $columns = $model->columns; $model = $model->columns(['id', 'number']);
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 include_model() is called.
include_model()
name
my $name = $model->name; $model = $model->name('book');
Model name.
(experimental) join
my $join = $model->join; $model = $model->join( ['left outer join company on book.company_id = company.id'] );
Default join clause. This is used by select().
select()
table
my $table = $model->table; $model = $model->table('book');
Table name. Model name and table name is different. Table name is real table name in database.
primary_key
my $primary_key = $model->primary_key; $model = $model->primary_key(['id', 'number']);
Foreign key. This is used by insert_at,update_at(), delete_at(),select_at().
insert_at
update_at()
delete_at()
select_at()
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_clause()
To create column clause automatically, use column_clause(). Valude of table and columns is used.
my $column_clause = $model->column_clause;
If table is 'book'�Acolumn is ['id', 'name'], the following clause is created.
column
book.id as id, book.name as name
These column name is for removing column name ambiguities.
If you remove some columns, use remove option.
remove
my $column_clause = $model->column_clause(remove => ['id']);
If you add some column, use add option.
add
my $column_clause = $model->column_clause(add => ['company.id as company__id']);
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.
method
$table->method( count => sub { my $self = shift; return $self->select(column => 'count(*)', @_) ->fetch_first->[0]; } );
Add method to a DBIx::Custom::Table object.
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()
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.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in ''book'�AC<column>'. Assuming CP1252
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.