use strict;
use warnings;
+use DBIx::ContextualFetch;
use NEXT;
use base qw/Class::Data::Inheritable/;
} );
sub db_Main {
- return $_[0]->_get_dbh;
+ return $_[0]->storage->dbh;
}
-sub _dbi_connect {
+sub connection {
my ($class, @info) = @_;
$info[3] = { %{ $info[3] || {}} };
$info[3]->{RootClass} = 'DBIx::ContextualFetch';
- return $class->NEXT::_dbi_connect(@info);
+ return $class->NEXT::connection(@info);
}
sub __driver {
- return $_[0]->_get_dbh->{Driver}->{Name};
+ return $_[0]->storage->dbh->{Driver}->{Name};
}
sub set_sql {
sub {
my $sql = $sql;
my $class = shift;
- return $class->_sql_to_sth($class->transform_sql($sql, @_));
+ return $class->storage->sth($class->transform_sql($sql, @_));
};
if ($sql =~ /select/i) {
my $meth = "sql_${name}";
*{"${class}::search_${name}"} =
sub {
my ($class, @args) = @_;
- $class->sth_to_objects($class->$meth, \@args);
+ my $sth = $class->$meth;
+ $sth->execute(@args);
+ return $class->sth_to_objects($sth);
};
}
}
+sub sth_to_objects {
+ my ($class, $sth) = @_;
+ my @cols = $class->_select_columns;
+ my @ret;
+ while (my @row = $sth->fetchrow_array) {
+ push(@ret, $class->_row_to_object(\@cols,\@row));
+ }
+ return @ret;
+}
+
sub transform_sql {
my ($class, $sql, @args) = @_;
my $table = $class->_table_name;
return sprintf($sql, @args);
}
+package DBIx::ContextualFetch::st;
+
+no warnings 'redefine';
+
+sub _untaint_execute {
+ my $sth = shift;
+ my $old_value = $sth->{Taint};
+ $sth->{Taint} = 0;
+ my $ret;
+ {
+ no warnings 'uninitialized';
+ $ret = $sth->SUPER::execute(@_);
+ }
+ $sth->{Taint} = $old_value;
+ return $ret;
+}
+
1;