in reply to Re: Class::DBI::AbstractSearch and SpeedyCGI
in thread Class::DBI::AbstractSearch and SpeedyCGI
The reason I thought it was the bind variable is that that's the only array I can see involved in this query - see the code below.
The stack, afaik, is something like this:
Here's the relevant lines in the PMs. Class::DBI::AbstractSearch:MyApp::Sets: my @res = Peeron2::Sets->search_where({ID => "8880-1"}); Class::DBI::AbstractSearch->search_where: return $class->retrieve_from_sql("( id = ? )", "8880-1"); # Class::DBI->retrieve_from_sql: $class->sth_to_objects($class->sql_Retrieve("id = ?")), ["8880-1"]); Class::DBI->sth_to_objects: $sth->execute("8880-1") unless $sth->{Active};
Class::DBI:sub search_where { my $class = shift; my $where = (ref $_[0]) ? $_[0] : { @_ }; my $attr = (ref $_[0]) ? $_[1] : undef; my $order = ($attr) ? delete($attr->{order_by}) : undef; # order is deprecated, but still backward compatible if ($attr && exists($attr->{order})) { $order = delete($attr->{order}); } $class->can('retrieve_from_sql') or do { require Carp; Carp::croak("$class should inherit from Class::DBI >= 0.90"); }; my $sql = SQL::Abstract->new(%$attr); my($phrase, @bind) = $sql->where($where, $order); $phrase =~ s/^\s*WHERE\s*//i; return $class->retrieve_from_sql($phrase, @bind); # <------------- +--31 }
sub retrieve_from_sql { my ($class, $sql, @vals) = @_; $sql =~ s/^\s*(WHERE)\s*//i; return $class->sth_to_objects($class->sql_Retrieve($sql), \@va +ls); } ... sub sth_to_objects { my ($class, $sth, $args) = @_; $class->_croak("sth_to_objects needs a statement handle") unle +ss $sth; unless (UNIVERSAL::isa($sth => "DBI::st")) { my $meth = "sql_$sth"; $sth = $class->$meth(); } my (%data, @rows); eval { $sth->execute(@$args) unless $sth->{Active}; # <------ +--------- 1124 $sth->bind_columns(\(@data{ @{ $sth->{NAME_lc} } })); push @rows, {%data} while $sth->fetch; }; return $class->_croak("$class can't $sth->{Statement}: $@", er +r => $@) if $@; return $class->_ids_to_objects(\@rows); }
-- zigdon
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Class::DBI::AbstractSearch and SpeedyCGI
by zigdon (Deacon) on Oct 04, 2005 at 11:14 UTC | |
by perrin (Chancellor) on Oct 04, 2005 at 18:28 UTC | |
by zigdon (Deacon) on Oct 04, 2005 at 20:09 UTC | |
by perrin (Chancellor) on Oct 04, 2005 at 20:50 UTC | |
by zigdon (Deacon) on Oct 05, 2005 at 02:41 UTC | |
|
In Section
Seekers of Perl Wisdom