| DBIx-Class documentation | Contained in the DBIx-Class distribution. |
DBIx::Class::Storage::DBI::InterBase - Driver for the Firebird RDBMS via DBD::InterBase
This driver is a subclass of DBIx::Class::Storage::DBI::Firebird::Common for use with DBD::InterBase, see that driver for general details.
You need to use either the
disable_sth_caching option or
connect_call_use_softcommit (see CAVEATS) for your code to function
correctly with this driver. Otherwise you will likely get bizarre error messages
such as no statement executing. The alternative is to use the
ODBC driver, which is more suitable
for long running processes such as under Catalyst.
To turn on DBIx::Class::InflateColumn::DateTime support, see connect_call_datetime_setup.
Used as:
on_connect_call => 'use_softcommit'
In connect_info to set the
DBD::InterBase ib_softcommit option.
You need either this option or disable_sth_caching => 1 for
DBIx::Class code to function correctly (otherwise you may get no statement
executing errors.) Or use the ODBC
driver.
The downside of using this option is that your process will NOT see UPDATEs, INSERTs and DELETEs from other processes for already open statements.
Used as:
on_connect_call => 'datetime_setup'
In connect_info to set the date and timestamp formats using:
$dbh->{ib_time_all} = 'ISO';
See DBD::InterBase for more details.
The TIMESTAMP data type supports up to 4 digits after the decimal point for
second precision. The full precision is used.
The DATE data type stores the date portion only, and it MUST be declared
with:
data_type => 'date'
in your Result class.
Timestamp columns can be declared with either datetime or timestamp.
You will need the DateTime::Format::Strptime module for inflation to work.
For DBIx::Class::Storage::DBI::ODBC::Firebird, this is a noop.
no statement executing errors, this of course adversely
affects performance.
You may distribute this code under the same terms as Perl itself.
| DBIx-Class documentation | Contained in the DBIx-Class distribution. |
package DBIx::Class::Storage::DBI::InterBase; use strict; use warnings; use base qw/DBIx::Class::Storage::DBI::Firebird::Common/; use mro 'c3'; use Try::Tiny; use namespace::clean;
__PACKAGE__->datetime_parser_type( 'DBIx::Class::Storage::DBI::InterBase::DateTime::Format' ); sub _ping { my $self = shift; my $dbh = $self->_dbh or return 0; local $dbh->{RaiseError} = 1; local $dbh->{PrintError} = 0; return try { $dbh->do('select 1 from rdb$database'); 1; } catch { 0; }; } # We want dialect 3 for new features and quoting to work, DBD::InterBase uses # dialect 1 (interbase compat) by default. sub _init { my $self = shift; $self->_set_sql_dialect(3); } sub _set_sql_dialect { my $self = shift; my $val = shift || 3; my $dsn = $self->_dbi_connect_info->[0]; return if ref($dsn) eq 'CODE'; if ($dsn !~ /ib_dialect=/) { $self->_dbi_connect_info->[0] = "$dsn;ib_dialect=$val"; my $connected = defined $self->_dbh; $self->disconnect; $self->ensure_connected if $connected; } }
sub connect_call_use_softcommit { my $self = shift; $self->_dbh->{ib_softcommit} = 1; }
sub connect_call_datetime_setup { my $self = shift; $self->_get_dbh->{ib_time_all} = 'ISO'; } package # hide from PAUSE DBIx::Class::Storage::DBI::InterBase::DateTime::Format; my $timestamp_format = '%Y-%m-%d %H:%M:%S.%4N'; # %F %T my $date_format = '%Y-%m-%d'; my ($timestamp_parser, $date_parser); sub parse_datetime { shift; require DateTime::Format::Strptime; $timestamp_parser ||= DateTime::Format::Strptime->new( pattern => $timestamp_format, on_error => 'croak', ); return $timestamp_parser->parse_datetime(shift); } sub format_datetime { shift; require DateTime::Format::Strptime; $timestamp_parser ||= DateTime::Format::Strptime->new( pattern => $timestamp_format, on_error => 'croak', ); return $timestamp_parser->format_datetime(shift); } sub parse_date { shift; require DateTime::Format::Strptime; $date_parser ||= DateTime::Format::Strptime->new( pattern => $date_format, on_error => 'croak', ); return $date_parser->parse_datetime(shift); } sub format_date { shift; require DateTime::Format::Strptime; $date_parser ||= DateTime::Format::Strptime->new( pattern => $date_format, on_error => 'croak', ); return $date_parser->format_datetime(shift); } 1;
# vim:sts=2 sw=2: