Commit | Line | Data |
2a57124d |
1 | package DBIx::Class::Storage::DBI::ODBC; |
2 | use strict; |
3 | use warnings; |
4 | |
5 | use base qw/DBIx::Class::Storage::DBI/; |
6 | |
7 | sub _rebless { |
8 | my ($self) = @_; |
9 | |
d40080c3 |
10 | my $dbtype = eval { $self->dbh->get_info(17) }; |
2a57124d |
11 | unless ( $@ ) { |
12 | # Translate the backend name into a perl identifier |
13 | $dbtype =~ s/\W/_/gi; |
4a9a13c8 |
14 | my $subclass = "DBIx::Class::Storage::DBI::ODBC::${dbtype}"; |
15 | if ($self->load_optional_class($subclass) && !$self->isa($subclass)) { |
16 | bless $self, $subclass; |
17 | $self->_rebless; |
18 | } |
2a57124d |
19 | } |
20 | } |
21 | |
455833d9 |
22 | sub _dbh_last_insert_id { |
23 | my ($self, $dbh, $source, $col) = @_; |
24 | |
25 | # punt: if there is no derived class for the specific backend, attempt |
26 | # to use the DBI->last_insert_id, which may not be sufficient (see the |
27 | # discussion of last_insert_id in perldoc DBI) |
28 | return $dbh->last_insert_id(undef, undef, $source->from, $col); |
29 | } |
2a57124d |
30 | |
31 | 1; |
32 | |
33 | =head1 NAME |
34 | |
35 | DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers |
36 | |
37 | =head1 SYNOPSIS |
38 | |
39 | # In your table classes |
40 | __PACKAGE__->load_components(qw/Core/); |
41 | |
42 | |
43 | =head1 DESCRIPTION |
44 | |
45 | This class simply provides a mechanism for discovering and loading a sub-class |
46 | for a specific ODBC backend. It should be transparent to the user. |
47 | |
48 | |
49 | =head1 AUTHORS |
50 | |
c1e64353 |
51 | Marc Mims C<< <marc@questright.com> >> |
2a57124d |
52 | |
53 | =head1 LICENSE |
54 | |
55 | You may distribute this code under the same terms as Perl itself. |
56 | |
57 | =cut |