1 package DBIx::Class::Storage::DBI::Sybase;
6 use base qw/DBIx::Class::Storage::DBI/;
8 use Carp::Clan qw/^DBIx::Class/;
13 if (ref($self) eq 'DBIx::Class::Storage::DBI::Sybase') {
15 @{$self->dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
20 my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";
22 if (!$exception && $dbtype && $self->load_optional_class($subclass)) {
23 bless $self, $subclass;
25 } elsif (not $self->dbh->{syb_dynamic_supported}) {
26 # probably real Sybase
27 bless $self, 'DBIx::Class::Storage:DBI::Sybase::NoBindVars';
34 my $old_dbd_warned = 0;
38 $self->next::method(@_);
39 my $dbh = $self->_dbh;
41 if ($dbh->can('syb_date_fmt')) {
42 $dbh->syb_date_fmt('ISO_strict');
43 } elsif (not $old_dbd_warned) {
44 carp "Your DBD::Sybase is too old to support ".
45 "DBIx::Class::InflateColumn::DateTime, please upgrade!";
49 $dbh->do('set dateformat mdy');
55 sub _dbh_last_insert_id {
56 my ($self, $dbh, $source, $col) = @_;
58 # sorry, there's no other way!
59 my $sth = $dbh->prepare_cached("select max($col) from ".$source->from);
60 return ($dbh->selectrow_array($sth))[0];
63 sub datetime_parser_type { "DBIx::Class::Storage::DBI::Sybase::DateTime" }
69 DBIx::Class::Storage::DBI::Sybase - Storage::DBI subclass for Sybase
73 This subclass supports L<DBD::Sybase> for real Sybase databases. If
74 you are using an MSSQL database via L<DBD::Sybase>, see
75 L<DBIx::Class::Storage::DBI::Sybase::MSSQL>.
79 If your version of Sybase does not support placeholders, then this storage
80 driver uses L<DBIx::Class::Storage::DBI::NoBindVars> as a base,
82 In which case, bind variables will be interpolated (properly quoted of course)
83 into the SQL query itself, without using bind placeholders.
85 More importantly this means that caching of prepared statements is explicitly
86 disabled, as the interpolation renders it useless.
88 If your version of Sybase B<DOES> support placeholders (check
89 C<<$dbh->{syb_dynamic_supported}>> then unfortunately there's no way to get the
90 C<last_insert_id> without doing a C<select max(col)>.
92 But your queries will be cached.
96 On connection C<syb_date_fmt> is set to C<ISO_strict>, e.g.:
97 C<2004-08-21T14:36:48.080Z> and C<dateformat> is set to C<mdy>, e.g.:
100 You will need the L<DateTime::Format::Strptime> module if you are going to use
101 L<DBIx::Class::InflateColumn::DateTime>.
105 Brandon L Black <blblack@gmail.com>
107 Justin Hunter <justin.d.hunter@gmail.com>
109 Rafael Kitover <rkitover@cpan.org>
113 You may distribute this code under the same terms as Perl itself.