NAME
DBIx::StORM::Class - A parent class for classes that would like to back onto a DBIx::StORM::Table and have records blessed into their own class.
SYNOPSIS
package MyClass;
use base "DBIx::StORM::Class";
__PACKAGE__->config(
connection => ["DBI:mysql:database=mydb", "username", "password"],
table => "MyTable",
);
DESCRIPTION
This is a base class that can be used to turn a DBIx::StORM::Table into a class in another package.
This class inherits from DBIx::StORM::Record and adds methods to access the records in a given table. Any records accessed will be automatically blessed into this class.
You can extend your subclass to add new methods for your class. You can also use a private stash to store transient information on your object.
METHODS
CONFIG
A static method to set up the class. It takes a hash which supports the following keys
connection (required)
Specify connection information. This is usually an array reference of the parameters to be passed to DBI->connect, but could also be a string which is treated as a package name of another DBIx::StORM::Class subclass to borrow the connection from, or a subroutine reference which must return an object of class DBIx::StORM.
table (required)
The string name of the table to store objects of this class in to. It must be available on the connection specified above.
NEW
This constructor is used to create new record objects before they are inserted into the database. You can subclass this to initialise new objects, and then write the record to the database by using the inherited commit call.
_INIT
This method is called after construction of a record object. Unlike new() it is also called for objects that are created from an existing database record. The default method does nothing, but you can override it to add additional initialisation.
_STASH
Returns a hash reference to a private per-object data store. It is in-memory and is not stored across sessions, but can be used by the subclass to hold transient data.
ALL
Returns a DBIx::StORM::RecordSet of all the records in the table. Each record belongs to the subclass and can have subclass methods called on them.
GREP
Accepts a code reference as a filter and returns a DBIx::StORM::RecordSet for records in the table for which the filter returns true. Each record belongs to the subclass and can have subclass methods called on
SEE ALSO
L<DBI>
L<DBIx::StORM>
L<DBIx::StORM::Record>
L<DBIx::StORM::RecordSet>
AUTHOR
Luke Ross, <luke@lukeross.name>
COPYRIGHT AND LICENSE
Copyright (C) 2006-2008 by Luke Ross
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.0 or, at your option, any later version of Perl 5 you may have available.