1 package DBIx::Class::Storage::DBI::NoBindVars;
6 use base 'DBIx::Class::Storage::DBI';
10 DBIx::Class::Storage::DBI::NoBindVars - Sometime DBDs have poor to no support for bind variables
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>
22 We can't cache very effectively without bind variables, so force the C<disable_sth_caching> setting to be turned on when the connect info is set.
28 my $retval = $self->next::method(@_);
29 $self->disable_sth_caching(1);
33 =head2 _prep_for_execute
35 Manually subs in the values for the usual C<?> placeholders.
39 sub _prep_for_execute {
42 my ($op, $extra_bind, $ident) = @_;
44 my ($sql, $bind) = $self->next::method(@_);
46 # stringify args, quote via $dbh, and manually insert
48 my @sql_part = split /\?/, $sql;
51 foreach my $bound (@$bind) {
52 my $col = shift @$bound;
53 my $do_quote = $self->should_quote_data_type($col);
54 foreach my $data (@$bound) {
58 $data = $self->_dbh->quote($data) if $do_quote;
59 $new_sql .= shift(@sql_part) . $data;
62 $new_sql .= join '', @sql_part;
67 =head2 should_quote_data_type
69 This method is called by L</_prep_for_execute> for every column in
70 order to determine if its value should be quoted or not. The sole
71 argument is the current column data type, and the return value is
72 interpreted as: true - do quote, false - do not quote. You should
73 override this in you Storage::DBI::<database> subclass, if your
74 RDBMS does not like quotes around certain datatypes (e.g. Sybase
75 and integer columns). The default method always returns true (do
80 sub should_quote_data_type { 1 }
84 Brandon Black <blblack@gmail.com>
86 Trym Skaar <trym@tryms.no>
90 You may distribute this code under the same terms as Perl itself.