DESCRIPTION

CGI::Application::Plugin::DBIC::Schema adds easy access to a DBIx::Class::Schema to your Titanium or CGI::Application modules. Lazy loading is used to prevent a database connection from being made if the schema method is not called during the request. In other words, the database connection is not created until it is actually needed.

DBIx::Class has lots of dependencies, and therefore a certain length of compile time, but it works fine in a CGI environment for low volume sites. If you expect a high volume of traffic, think about FastCGI or other alternatives.

METHODS

schema($name?)

This method will return the default DBIx::Class::Schema instance if no name is provided. Provide a schema name to retrieve an alternate schema. The schema instance is created on the first call to this method, and any subsequent calls will return the same instance.

dbic_config($name?, \%connect_info)

Used to provide your DBIx::Class::Schema class name, an optional config name, and DBI connection parameters. For \%config_info supply the same parameter list that you would for DBI::connect. You may also supply DBIx::Class specifig attributes. For that see DBIx::Class::Storage::DBI for details.

The recommended place to call dbic_config is in the cgiapp_init stage of CGI::Application. If this method is called after the dbic() method has already been accessed, then it will die with an error message.

resultset($config_name?,$resultset_classname)

An alias to $c->schema(...)->resultset(...).

This method provides DBIx::Class::Resultset access.

# Use the default dbic schema via 'resultset'.
$c->resultset("DBICT::Result::Test")->find($id);
# Or use a named config to access resultset via an alternative schema.
$c->resultset('another_config', "DBICT::Result::Test")->find($id);
# Or use alias short form, 'rs' with default config
$c->rs("DBICT::Result::Test")->find($id);
# Or use alias short form with alternate config/schema
$c->rs('yet_another_schema', "DBICT::Result::Test")->find($id);