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 Uses C<prepare> instead of the usual C<prepare_cached>, seeing as we can't cache very effectively without bind variables.
27 my ($self, $sql) = @_;
28 return $self->dbh->prepare($sql);
33 Manually subs in the values for the usual C<?> placeholders before calling L</sth> on the generated SQL.
38 my ($self, $op, $extra_bind, $ident, @args) = @_;
39 my ($sql, @bind) = $self->sql_maker->$op($ident, @args);
40 unshift(@bind, @$extra_bind) if $extra_bind;
42 my @debug_bind = map { defined $_ ? qq{'$_'} : q{'NULL'} } @bind;
43 $self->debugobj->query_start($sql, @debug_bind);
46 while(my $bvar = shift @bind) {
47 $bvar = $self->_dbh->quote($bvar);
51 my $sth = eval { $self->sth($sql,$op) };
54 $self->throw_exception(
55 'no sth generated via sql (' . ($@ || $self->_dbh->errstr) . "): $sql"
62 $rv = eval { $sth->execute };
65 $self->throw_exception("Error executing '$sql': ".($@ || $sth->errstr));
68 $self->throw_exception("'$sql' did not generate a statement.");
71 my @debug_bind = map { defined $_ ? qq{`$_'} : q{`NULL'} } @bind;
72 $self->debugobj->query_end($sql, @debug_bind);
74 return (wantarray ? ($rv, $sth, @bind) : $rv);
79 Brandon Black <blblack@gmail.com>
81 Trym Skaar <trym@tryms.no>
85 You may distribute this code under the same terms as Perl itself.