NAME
DBIx::Class::Storage::DBI - DBI storage handler
SYNOPSIS
DESCRIPTION
This class represents the connection to the database
METHODS
connect_info
Connection information arrayref. Can either be the same arguments one would pass to DBI->connect, or a code-reference which returns a connected database handle. In either case, there is an optional final element in the arrayref, which can hold a hashref of connection-specific Storage::DBI options. These include on_connect_do
, and the sql_maker options limit_dialect
, quote_char
, and name_sep
. Examples:
->connect_info([ 'dbi:SQLite:./foo.db' ]);
->connect_info(sub { DBI->connect(...) });
->connect_info([ 'dbi:Pg:dbname=foo',
'postgres',
'',
{ AutoCommit => 0 },
{ quote_char => q{`}, name_sep => q{@} },
]);
on_connect_do
Executes the sql statements given as a listref on every db connect.
quote_char
Specifies what characters to use to quote table and column names. If you use this you will want to specify name_sep as well.
quote_char expectes either a single character, in which case is it is placed on either side of the table/column, or an array of length 2 in which case the table/column name is placed between the elements.
For example under MySQL you'd use quote_char('`')
, and user SQL Server you'd use quote_char(qw/[ ]/)
.
name_sep
This only needs to be used in conjunction with quote_char, and is used to specify the charecter that seperates elements (schemas, tables, columns) from each other. In most cases this is simply a .
.
debug
Causes SQL trace information to be emitted on the debugobj
object. (or STDERR
if debugobj
has not specifically been set).
debugfh
Set or retrieve the filehandle used for trace/debug output. This should be an IO::Handle compatible ojbect (only the print
method is used. Initially set to be STDERR - although see information on the DBIX_CLASS_STORAGE_DBI_DEBUG environment variable.
debugobj
Sets or retrieves the object used for metric collection. Defaults to an instance of DBIx::Class::Storage::Statistics that is campatible with the original method of using a coderef as a callback. See the aforementioned Statistics class for more information.
debugcb
Sets a callback to be executed each time a statement is run; takes a sub reference. Callback is executed as $sub->($op, $info) where $op is SELECT/INSERT/UPDATE/DELETE and $info is what would normally be printed.
See debugobj for a better way.
dbh
Returns the dbh - a data base handle of class DBI.
txn_begin
Calls begin_work on the current dbh.
See DBIx::Class::Schema for the txn_do() method, which allows for an entire code block to be executed transactionally.
txn_commit
Issues a commit against the current dbh.
txn_rollback
Issues a rollback against the current dbh. A nested rollback will throw a DBIx::Class::Storage::NESTED_ROLLBACK_EXCEPTION exception, which allows the rollback to propagate to the outermost transaction.
columns_info_for
Returns database type info for a given table columns.
ENVIRONMENT VARIABLES
DBIX_CLASS_STORAGE_DBI_DEBUG
If DBIX_CLASS_STORAGE_DBI_DEBUG
is set then SQL trace information is produced (as when the debug method is set).
If the value is of the form 1=/path/name
then the trace output is written to the file /path/name
.
This environment variable is checked when the storage object is first created (when you call connect on your schema). So, run-time changes to this environment variable will not take effect unless you also re-connect on your schema.
AUTHORS
Matt S. Trout <mst@shadowcatsystems.co.uk>
Andy Grundman <andy@hybridized.org>
LICENSE
You may distribute this code under the same terms as Perl itself.