1f5dfc48d82c20f2f6f67137a99c1d311c277209
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / Storage / DBI / Sybase / NoBindVars.pm
1 package DBIx::Class::Storage::DBI::Sybase::NoBindVars;
2
3 use Class::C3;
4 use base qw/
5   DBIx::Class::Storage::DBI::NoBindVars
6   DBIx::Class::Storage::DBI::Sybase
7 /;
8
9 sub _dbh_last_insert_id {
10   my ($self, $dbh, $source, $col) = @_;
11
12   # @@identity works only if not using placeholders
13   # Should this query be cached?
14   return ($dbh->selectrow_array('select @@identity'))[0];
15 }
16
17 1;
18
19 =head1 NAME
20
21 DBIx::Class::Storage::DBI::Sybase::NoBindVars - Storage::DBI subclass for Sybase
22 without placeholder support
23
24 =head1 DESCRIPTION
25
26 If you're using this driver than your version of Sybase does not support
27 placeholders. You can check with:
28
29   $dbh->{syb_dynamic_supported}
30
31 You can also enable this driver explicitly using:
32
33   my $schema = SchemaClass->clone;
34   $schema->storage_type('::DBI::Sybase::NoBindVars');
35   $schema->connect($dsn, $user, $pass, \%opts);
36
37 See the discussion in L<< DBD::Sybase/Using ? Placeholders & bind parameters to
38 $sth->execute >> for details on the pros and cons of using placeholders.
39
40 One advantage of not using placeholders is that C<select @@identity> will work
41 for obtainging the last insert id of an C<IDENTITY> column, instead of having to
42 do C<select max(col)> as the base Sybase driver does.
43
44 When using this driver, bind variables will be interpolated (properly quoted of
45 course) into the SQL query itself, without using placeholders.
46
47 The caching of prepared statements is also explicitly disabled, as the
48 interpolation renders it useless.
49
50 =head1 AUTHORS
51
52 See L<DBIx::Class/CONTRIBUTORS>.
53
54 =head1 LICENSE
55
56 You may distribute this code under the same terms as Perl itself.
57
58 =cut
59 # vim:sts=2 sw=2: