Commit | Line | Data |
3885cff6 |
1 | package DBIx::Class::Storage::DBI::NoBindVars; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use base 'DBIx::Class::Storage::DBI'; |
7 | |
b43345f2 |
8 | =head1 NAME |
9 | |
10 | DBIx::Class::Storage::DBI::NoBindVars - Sometime DBDs have poor to no support for bind variables |
11 | |
12 | =head1 DESCRIPTION |
13 | |
14 | This class allows queries to work when the DBD or underlying library does not |
15 | support the usual C<?> placeholders, or at least doesn't support them very |
16 | well, as is the case with L<DBD::Sybase> |
17 | |
18 | =head1 METHODS |
19 | |
20 | =head2 sth |
21 | |
22 | Uses C<prepare> instead of the usual C<prepare_cached>, seeing as we can't cache very effectively without bind variables. |
23 | |
24 | =cut |
25 | |
d5130dd2 |
26 | sub _dbh_sth { |
27 | my ($self, $dbh, $sql) = @_; |
28 | $dbh->prepare($sql); |
b43345f2 |
29 | } |
30 | |
d5130dd2 |
31 | =head2 _prep_for_execute |
b43345f2 |
32 | |
d5130dd2 |
33 | Manually subs in the values for the usual C<?> placeholders. |
b43345f2 |
34 | |
35 | =cut |
36 | |
d5130dd2 |
37 | sub _prep_for_execute { |
38 | my $self = shift; |
39 | my ($sql, @bind) = $self->next::method(@_); |
40 | |
41 | $sql =~ s/\?/$self->_dbh->quote($_)/e for (@bind); |
42 | |
43 | return ($sql); |
3885cff6 |
44 | } |
45 | |
3885cff6 |
46 | =head1 AUTHORS |
47 | |
48 | Brandon Black <blblack@gmail.com> |
b43345f2 |
49 | |
7762b22c |
50 | Trym Skaar <trym@tryms.no> |
3885cff6 |
51 | |
52 | =head1 LICENSE |
53 | |
54 | You may distribute this code under the same terms as Perl itself. |
55 | |
56 | =cut |
b43345f2 |
57 | |
58 | 1; |