[Bast-commits] r6912 - in DBIx-Class/0.08/branches: . syb_connected/lib/DBIx/Class/Storage/DBI syb_connected/lib/DBIx/Class/Storage/DBI/Sybase

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Wed Jul 1 13:21:31 GMT 2009


Author: caelum
Date: 2009-07-01 13:21:30 +0000 (Wed, 01 Jul 2009)
New Revision: 6912

Added:
   DBIx-Class/0.08/branches/syb_connected/
   DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm
Modified:
   DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase.pm
   DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm
Log:
new connected() for dbd::sybase users

Copied: DBIx-Class/0.08/branches/syb_connected (from rev 6909, DBIx-Class/0.08/trunk)

Added: DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm
===================================================================
--- DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm	                        (rev 0)
+++ DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm	2009-07-01 13:21:30 UTC (rev 6912)
@@ -0,0 +1,52 @@
+package DBIx::Class::Storage::DBI::Sybase::Base;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+DBIx::Class::Storage::DBI::Sybase::Base - Common functionality for drivers using
+L<DBD::Sybase>
+
+=head1 METHODS
+
+=head2 connected
+
+Returns true if we have an open (and working) database connection, false if it
+is not (yet) open (or does not work). (Executes a simple SELECT to make sure it
+works.)
+
+The reason this is needed is that L<DBD::Sybase>'s ping() does not work with an
+active statement handle, leading to masked database errors.
+
+=cut
+
+sub connected {
+  my $self = shift;
+
+  my $dbh = $self->_dbh;
+
+  local $dbh->{RaiseError} = 1;
+
+  my $ping_sth;
+
+  eval {
+    my $ping_sth = $dbh->prepare_cached("select 1");
+    $ping_sth->execute;
+    $ping_sth->finish;
+  };
+
+  return $@ ? 0 : 1;
+}
+
+1;
+
+=head1 AUTHORS
+
+See L<DBIx::Class/CONTRIBUTORS>.
+
+=head1 LICENSE
+
+You may distribute this code under the same terms as Perl itself.
+
+=cut

Modified: DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm	2009-07-01 11:27:15 UTC (rev 6909)
+++ DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm	2009-07-01 13:21:30 UTC (rev 6912)
@@ -2,10 +2,10 @@
 
 use strict;
 use warnings;
-
+use mro 'c3';
 use base qw/
+  DBIx::Class::Storage::DBI::Sybase::Base
   DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server
-  DBIx::Class::Storage::DBI::Sybase
 /;
 
 1;

Modified: DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-07-01 11:27:15 UTC (rev 6909)
+++ DBIx-Class/0.08/branches/syb_connected/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-07-01 13:21:30 UTC (rev 6912)
@@ -2,9 +2,12 @@
 
 use strict;
 use warnings;
+use mro 'c3';
+use base qw/
+    DBIx::Class::Storage::DBI::Sybase::Base
+    DBIx::Class::Storage::DBI::NoBindVars
+/;
 
-use base qw/DBIx::Class::Storage::DBI::NoBindVars/;
-
 sub _rebless {
     my $self = shift;
 




More information about the Bast-commits mailing list