Name
QBit::Application::Model::DB::Table
Description
Base class for DB tables.
RO accessors
name
inherits
primary_key
indexes
foreign_keys
Abstract methods
create_sql
add_multi
add
edit
delete
_get_field_object
_convert_fk_auto_type
Package methods
init
No arguments.
Method called from "new" before return object.
fields
No arguments.
Return values:
$fields - reference to array of objects (QBit::Application::Model::DB::Field)
Example:
my $fields = $app->db->users->fields();
fields
No arguments.
Return values:
@field_names
Example:
my @field_names = $app->db->users->field_names();
get_all
Arguments:
%opts - options with keys
fields
filter
group_by
order_by
limit
distinct
for_update
all_langs
For more information see QBit::Application::Model::DB::Query::get_all
Return values:
$data - reference to array
Example:
my $data = $app->db->users->get_all(
fields => [qw(id login)],
filter => {id => 3},
);
get
Arguments:
$id - scalar or hash
%opts - options with keys
fields
for_update
all_langs
For more information see QBit::Application::Model::DB::Query::get_all
Return values:
$data - reference to hash
Example:
my $data = $app->db->users->get(3, fields => [qw(id login)],);
truncate
No arguments.
Truncate table.
Example:
$app->db->users->truncate();
drop
Arguments:
%opts - options with keys
if_exists - added 'IF EXISTS'
Example:
$app->db->users->drop(); # DROP TABLE `users`;
$app->db->users->drop(if_exists => TRUE); # DROP TABLE IF EXISTS `users`;
default_fields
You can redefine this method in your Model.
default_primary_key
You can redefine this method in your Model.
default_indexes
You can redefine this method in your Model.
default_foreign_keys
You can redefine this method in your Model.
have_fields
Arguments:
$fields - reference to array
Return values:
$bool
Example:
my $bool = $app->db->users->have_fields([qw(id login)]);
For more information see code and test.