-
Notifications
You must be signed in to change notification settings - Fork 7
Create model
yuki-kimoto edited this page Oct 13, 2012
·
1 revision
Model is useful feature to execute query easily.
Create model by create_model
.
$dbi->create_model(table => 'book');
You get created model by model
method using table
name.
my $book_model = $dbi->model('book');
Model is DBIx::Custom::Model object. DBIx::Custom::Model has some methods, and can call all of DBIx::Custom methods.
my $result = $book_model->select;
create_model
method can set the following attributes, table
, primary_key
, join
, ctime
, mtime
.
$dbi->create_model(
table => 'book',
primary_key => 'id',
join => [
'left outer join company on book.company_id = company.id'
],
ctime => 'ctime',
mtime => 'mtime'
);
These attributes are used automatically when insert
, update
, delete
, select
methods is called from model.