fix segfault with old DBD::Sybase
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / Storage / DBI / Sybase / Base.pm
CommitLineData
eabab5d0 1package DBIx::Class::Storage::DBI::Sybase::Base;
2
3use strict;
4use warnings;
5
6=head1 NAME
7
8DBIx::Class::Storage::DBI::Sybase::Base - Common functionality for drivers using
2932b9a6 9DBD::Sybase
eabab5d0 10
11=head1 METHODS
12
13=head2 connected
14
15Returns true if we have an open (and working) database connection, false if it
16is not (yet) open (or does not work). (Executes a simple SELECT to make sure it
17works.)
18
19The reason this is needed is that L<DBD::Sybase>'s ping() does not work with an
20active statement handle, leading to masked database errors.
21
22=cut
23
24sub connected {
25 my $self = shift;
26
d7ffa0ce 27 my $dbh = $self->_dbh or return 0;
28 $dbh->FETCH('Active') or return 0;
29
526dc858 30 local $dbh->{RaiseError} = 1;
eabab5d0 31 eval {
283fb613 32 $dbh->do('select 1');
eabab5d0 33 };
34
35 return $@ ? 0 : 1;
36}
37
381;
39
40=head1 AUTHORS
41
42See L<DBIx::Class/CONTRIBUTORS>.
43
44=head1 LICENSE
45
46You may distribute this code under the same terms as Perl itself.
47
48=cut