new connected() for dbd::sybase users
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase.pm
1 package DBIx::Class::Storage::DBI::Sybase;
2
3 use strict;
4 use warnings;
5 use mro 'c3';
6 use base qw/
7     DBIx::Class::Storage::DBI::Sybase::Base
8     DBIx::Class::Storage::DBI::NoBindVars
9 /;
10
11 sub _rebless {
12     my $self = shift;
13
14     my $dbtype = eval { @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] };
15     unless ( $@ ) {
16         $dbtype =~ s/\W/_/gi;
17         my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";
18         if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
19             bless $self, $subclass;
20             $self->_rebless;
21         }
22     }
23 }
24
25 sub _dbh_last_insert_id {
26     my ($self, $dbh, $source, $col) = @_;
27     return ($dbh->selectrow_array('select @@identity'))[0];
28 }
29
30 1;
31
32 =head1 NAME
33
34 DBIx::Class::Storage::DBI::Sybase - Storage::DBI subclass for Sybase
35
36 =head1 SYNOPSIS
37
38 This subclass supports L<DBD::Sybase> for real Sybase databases.  If
39 you are using an MSSQL database via L<DBD::Sybase>, see
40 L<DBIx::Class::Storage::DBI::Sybase::MSSQL>.
41
42 =head1 CAVEATS
43
44 This storage driver uses L<DBIx::Class::Storage::DBI::NoBindVars> as a base.
45 This means that bind variables will be interpolated (properly quoted of course)
46 into the SQL query itself, without using bind placeholders.
47
48 More importantly this means that caching of prepared statements is explicitly
49 disabled, as the interpolation renders it useless.
50
51 =head1 AUTHORS
52
53 Brandon L Black <blblack@gmail.com>
54
55 Justin Hunter <justin.d.hunter@gmail.com>
56
57 =head1 LICENSE
58
59 You may distribute this code under the same terms as Perl itself.
60
61 =cut