Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: DB search results using DBI...execute

by poj (Abbot)
on Mar 04, 2017 at 21:25 UTC ( #1183671=note: print w/replies, xml ) Need Help??


in reply to DB search results using DBI...execute

Use Data::Dumper to show the structure

use Data::Dumper; print '<pre>'; print Dumper \@results; print '</pre>';

The code for search_item() looks to be more relevant to your question than sql_execute().

poj

Replies are listed 'Best First'.
Re^2: DB search results using DBI...execute
by jamroll (Beadle) on Mar 04, 2017 at 21:38 UTC
    yes! ty for that. not entirely certain how that helps...perhaps i'm misguided. i'm asking why the code gives back a 3...not if search_item() is more relevant than sql_execute(). frankly, your reply, although highly appreciated, makes little sense to me.
      my @results = search_item($dbh, \@users, $st, $sv) . "\n"; is slightly incorrect, btw - and not sure how the "\n" got in there....it's not there in my actual code. so, it should read just: my @results = search_item($dbh, \@users, $st, $sv);

        Try this simple cgi to show the benefit of using Dumper.

        #!perl # Dumper demo cgi use strict; use Data::Dumper; print "Content-Type: text/html\n\n"; print '<pre>'; my $ref = [ { ID => 'ABC'},{ ID => 'DEF'},{ ID => 'GHI'} ]; print '<h2>$ref</h2>'; print Dumper $ref; print '<hr/>'; my @array = map { $_->{ID} } @$ref; print '<h2>@array</h2>'; print Dumper @array; print '<hr/>'; my @error = @array."\n"; print '<h2>@error</h2>'; print Dumper @error; print '<hr/>';

        Also, note how map could be used to replace this code in search_item()

        my @array = @$resultsRef foreach my $hit (@array) { # $hit is a hash reference. my %hash = %$hit; push @searched, $hash{ID}; }
        poj

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1183671]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2021-11-28 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?