=head1 METHODS
-=over 4
-
=cut
sub mk_group_accessors {
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=head1 METHODS
-=over 4
+=head2 storage
+Sets or gets the storage backend. Defaults to L<DBIx::Class::Storage::DBI>.
-=item storage
+=head2 class_resolver
-Which storage backend to be used. Defaults to L<DBIx::Class::Storage::DBI>
-
-=item class_resolver
-
-Which class to use for resolving a class. Defaults to
-L<DBIx::Class::ClassResolver::Passthrough>, which returns whatever you throw
-at it. See resolve_class below.
+Sets or gets the class to use for resolving a class. Defaults to
+L<DBIx::Class::ClassResolver::Passthrough>, which returns whatever you give
+it. See resolve_class below.
=cut
__PACKAGE__->mk_classdata('class_resolver' =>
'DBIx::Class::ClassResolver::PassThrough');
-=item connection
+=head2 connection
__PACKAGE__->connection($dsn, $user, $pass, $attrs);
$class->storage($storage);
}
-=item dbi_commit
-
- $class->dbi_commit;
+=head2 dbi_commit
-Issues a commit again the current dbh
+Issues a commit against the current dbh.
=cut
sub dbi_commit { $_[0]->storage->commit; }
-=item dbi_rollback
+=head2 dbi_rollback
- $class->dbi_rollback;
-
-Issues a rollback again the current dbh
+Issues a rollback against the current dbh.
=cut
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=head1 METHODS
-=over 4
+=head2 throw( $message )
-=item throw( $message )
+=head2 throw( message => $message )
-=item throw( message => $message )
-
-=item throw( error => $error )
+=head2 throw( error => $error )
Throws a fatal exception.
Carp::croak($message);
}
-=back
-
=head1 AUTHOR
Marcus Ramberg <mramberg@cpan.org>
=head1 SECTIONS
-=over 4
-
-=item L<DBIx::Class::Manual::Intro>
+=head2 L<DBIx::Class::Manual::Intro>
A beginner's introduction to using the native DBIx::Class interface
-=item L<DBIx::Class::Manual::Cookbook>
+=head2 L<DBIx::Class::Manual::Cookbook>
Convenient reciepes for DBIC usage.
-=item L<DBIx::Class::Manual::FAQ>
+=head2 L<DBIx::Class::Manual::FAQ>
Frequently asked questions about DBIC.
-=item L<DBIx::Class::Manual::Troubleshooting>
+=head2 L<DBIx::Class::Manual::Troubleshooting>
Got trouble? Let us shoot it for you.
-=back
-
If you're using the CDBI Compat layer, we suggest reading the L<Class::DBI>
documentation. It should behave the same way.
=head1 RECIPES
-=item Input validation.
+=head2 Input validation.
-=item Using joins
+=head2 Using joins
-=item Many-to-many relationships
+=head2 Many-to-many relationships
This is not as easy as it could be, but it's possible. Here's an example to
illustrate:
# book2author table equals the bookID of the books (using the bookID
# relationship table
-=item Advanced Exception handling
+=head2 Advanced Exception handling
-=item Transactions
+=head2 Transactions
=back
=head1 QUESTIONS
-=over 4
+=head2 What is the point of this module? Is it a fork of Class::DBI?
-=item What is the point of this module? Is it a fork of Class::DBI?
+=head2 Who's the intended audience for this module?
-=item Who's the intended audience for this module?
+=head2 What databases does it support?
-=item What databases does it support?
+=head2 What's the current status of this module?
-=item What's the current status of this module?
+=head2 What's planned in the future?
-=item What's planned in the future?
-
-=item Where can I go for support?
-
-=back
+=head2 Where can I go for support?
=cut
DBIx::Class::Manual::Troubleshooting - Got a problem? Shoot it.
-=over 4
-
-=item "Can't locate storage blabla"
-
-=back
+=head2 "Can't locate storage blabla"
=cut
=head1 SYNOPSIS
# in your class definition
- use Cache::FastMmmap;
+ use Cache::FastMmap;
__PACKAGE__->cache(Cache::FastMmap->new);
=head1 DESCRIPTION
=head1 AUTHORS
-David Kamholz <davekam@pobox.com>
+David Kamholz <dkamholz@cpan.org>
=head1 LICENSE
=head1 METHODS
-=over 4
-
=cut
sub _ident_cond {
return (map { $self->{_column_data}{$_} } keys %{$self->_primaries});
}
-=item set_primary_key <@cols>
+=head2 set_primary_key <@cols>
define one or more columns as primary key for this class
$class->_primaries(\%pri);
}
-=item find
+=head2 find
Finds columns based on the primary key(s).
return (@row ? $class->_row_to_object(\@cols, \@row) : ());
}
-=item discard_changes
+=head2 discard_changes
Roll back changes that hasn't been comitted to the database.
return $self;
}
-=item id
+=head2 id
returns the primary key(s) for the current row. Can't be called as
a class method.
return (wantarray ? @pk : $pk[0]);
}
-=item primary_columns
+=head2 primary_columns
read-only accessor which returns a list of primary keys.
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=head1 METHODS
-=over 4
-
-=item insert
+=head2 insert
Overrides insert so that it will get the value of autoincremented
primary keys.
return $ret;
}
-=item sequence
+=head2 sequence
Manually define the correct sequence for your table, to avoid the overhead
associated with looking up the sequence automatically.
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
you want to use the default value for it, but still want to set C<$attrs>.
The following attributes are recognize:
-=over 4
-
-=item join_type
+=head2 join_type
Explicitly specifies the type of join to use in the relationship. Any SQL
join type is valid, e.g. C<LEFT> or C<RIGHT>. It will be placed in the SQL
command immediately before C<JOIN>.
-=item proxy
+=head2 proxy
An arrayref containing a list of accessors in the foreign class to proxy in
the main class. If, for example, you do the following:
my $obj = Foo->find(1);
$obj->margle(10); # set margle; Bar object is created if it doesn't exist
-=back
-
=head2 belongs_to
my $f_obj = $obj->relname;
=head1 METHODS
-=over 4
-
-=item add_relationship
+=head2 add_relationship
__PACKAGE__->add_relationship('relname', 'Foreign::Class', $cond, $attrs);
return $self->next::method($attrs, $key, $value)
}
-=item search_related
+=head2 search_related
My::Table->search_related('relname', $cond, $attrs);
return $self->_query_related('search', @_);
}
-=item count_related
+=head2 count_related
My::Table->count_related('relname', $cond, $attrs);
)->$meth($query, $attrs);
}
-=item create_related
+=head2 create_related
My::Table->create_related('relname', \%col_data);
return $class->new_related(@_)->insert;
}
-=item new_related
+=head2 new_related
My::Table->new_related('relname', \%col_data);
return $self->resolve_class($rel_obj->{class})->new(\%fields);
}
-=item find_related
+=head2 find_related
My::Table->find_related('relname', @pri_vals | \%pri_vals);
return $self->resolve_class($rel_obj->{class})->find($query);
}
-=item find_or_create_related
+=head2 find_or_create_related
My::Table->find_or_create_related('relname', \%col_data);
return $self->find_related(@_) || $self->create_related(@_);
}
-=item set_from_related
+=head2 set_from_related
My::Table->set_from_related('relname', $rel_obj);
return 1;
}
-=item update_from_related
+=head2 update_from_related
My::Table->update_from_related('relname', $rel_obj);
$self->update;
}
-=item delete_related
+=head2 delete_related
My::Table->delete_related('relname', $cond, $attrs);
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=head1 METHODS
-=over 4
-
-=item new
+=head2 new
my $obj = My::Class->new($attrs);
return $new;
}
-=item insert
+=head2 insert
$obj->insert;
return $self;
}
-=item in_storage
+=head2 in_storage
$obj->in_storage; # Get value
$obj->in_storage(1); # Set value
return $self->{_in_storage};
}
-=item create
+=head2 create
my $new = My::Class->create($attrs);
return $class->new($attrs)->insert;
}
-=item update
+=head2 update
$obj->update;
return $self;
}
-=item delete
+=head2 delete
$obj->delete
return $self;
}
-=item get_column
+=head2 get_column
my $val = $obj->get_column($col);
return undef;
}
-=item get_columns
+=head2 get_columns
my %data = $obj->get_columns;
return map { $_ => $self->get_column($_) } $self->columns;
}
-=item set_column
+=head2 set_column
$obj->set_column($col => $val);
return $ret;
}
-=item set_columns
+=head2 set_columns
my $copy = $orig->set_columns({ $col => $val, ... });
}
}
-=item copy
+=head2 copy
my $copy = $orig->copy({ change => $to, ... });
=cut
-=item store_column
+=head2 store_column
$obj->store_column($col => $val);
return $new->insert;
}
-=item insert_or_update
+=head2 insert_or_update
$obj->insert_or_update
return ($self->in_storage ? $self->update : $self->insert);
}
-=item is_changed
+=head2 is_changed
my @changed_col_names = $obj->is_changed
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=head1 METHODS
-=over 4
-
-=item register_class <component> <component_class>
+=head2 register_class <component> <component_class>
Registers the class in the schema's class_registrations. This is a hash
containing database classes, keyed by their monikers. It's used by
$class->class_registrations(\%reg);
}
-=item registered_classes
+=head2 registered_classes
Simple read-only accessor for the schema's registered classes. See
register_class above if you want to modify it.
return values %{shift->class_registrations};
}
-=item load_classes [<classes>, (<class>, <class>), {<namespace> => [<classes>]}]
+=head2 load_classes [<classes>, (<class>, <class>), {<namespace> => [<classes>]}]
Uses L<Module::Find> to find all classes under the database class' namespace,
or uses the classes you select. Then it loads the component (using L<use>),
}
}
-=item compose_connection <target> <@db_info>
+=head2 compose_connection <target> <@db_info>
This is the most important method in this class. it takes a target namespace,
as well as dbh connection info, and creates a L<DBIx::Class::DB> class as
$conn_class->class_resolver($target);
}
-=item setup_connection_class <$target> <@info>
+=head2 setup_connection_class <$target> <@info>
Sets up a database connection class to inject between the schema
and the subclasses the schema creates.
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=head1 METHODS
-=over 4
-
=cut
sub dbh {
return DBI->connect(@info);
}
-=item commit
+=head2 commit
$class->commit;
sub commit { $_[0]->dbh->commit; }
-=item rollback
+=head2 rollback
$class->rollback;
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=head1 METHODS
-=over 4
-
=cut
sub _register_columns {
$class->mk_group_accessors('column' => @cols);
}
-=item add_columns
+=head2 add_columns
__PACKAGE__->add_columns(qw/col1 col2 col3/);
$class->_mk_column_accessors(@cols);
}
-=item search_literal
+=head2 search_literal
my @obj = $class->search_literal($literal_where_cond, @bind);
my $cursor = $class->search_literal($literal_where_cond, @bind);
return $class->search(\$cond, $attrs);
}
-=item count_literal
+=head2 count_literal
my $count = $class->count_literal($literal_where_cond);
return $class->search_literal(@_)->count;
}
-=item count
+=head2 count
my $count = $class->count({ foo => 3 });
return $class->search(@_)->count;
}
-=item search
+=head2 search
my @obj = $class->search({ foo => 3 }); # "... WHERE foo = 3"
my $cursor = $class->search({ foo => 3 });
my $rs = $rs_class->new($class, @_);
}
-=item search_like
+=head2 search_like
Identical to search except defaults to 'LIKE' instead of '=' in condition
return keys %{$_[0]->_columns};
}
-=item table
+=head2 table
__PACKAGE__->table('tbl_name');
shift->_table_name(@_);
}
-=item find_or_create
+=head2 find_or_create
$class->find_or_create({ key => $val, ... });
return defined($exists) ? $exists : $class->create($hash);
}
-=item has_column
+=head2 has_column
if ($obj->has_column($col)) { ... }
return exists $self->_columns->{$column};
}
-=item column_info
+=head2 column_info
my $info = $obj->column_info($col);
return $self->_columns->{$column};
}
-=item columns
+=head2 columns
my @column_names = $obj->columns;
1;
-=back
-
=head1 AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
=head1 METHODS
-=over 4
-
-=item uuid_columns
+=head2 uuid_columns
=cut
return Data::UUID->new->to_string(Data::UUID->new->create),
}
-=back
-
=head1 AUTHORS
Chia-liang Kao <clkao@clkao.org>