Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Help with fetching a single result from a table

by barrycarlyon (Beadle)
on Mar 24, 2006 at 14:45 UTC ( [id://539034]=perlquestion: print w/replies, xml ) Need Help??

barrycarlyon has asked for the wisdom of the Perl Monks concerning the following question:

Ive been trying for ages and I cant do this so...

Im trying to fetch a single result from a table. First I search the table for the right row, but i want to fetch a single column so then I can search another database with the returned value

table;

id field content date

I search the field, but I want to put the content in a refernece then search a different database with that response

somewhat like

--CODE--

# search first db my $data => LSRfm::Database::Data->search(field => 'currentpoll'); # returns an array but I only want the third column of the array which + is called content my @results = LSRfm::Database::Poll_Results->search(poll_title => (--Search using content--));
--END CODE--

--Search using content-- = Search using $data but only using the content field in that array.

I think that explains it?!

BarryCarlyon

barry@barrycarlyon.co.uk

www.lsrfm.com

Edit: g0n - code tags

Replies are listed 'Best First'.
Re: Help with fetching a single result from a table
by davidrw (Prior) on Mar 24, 2006 at 14:55 UTC
    If $data is an array ref, then "--Search using content--" is just $data->[2] ... is that all you need? (i.e. i assume the ->search method exist and aren't just pseudocode)
    For debugging, try use Data::Dumper; die Dumper $data; so you can see what $data looks like.

    I also suspect that my $data = should be my ($data) = but i can't say w/o knowing what the ->search() method returns .. if it returns an iterator (e.g. Class::DBI->search does) in scalar context, then you wan the parens to force array context and just get the first element. (I also note that your second call to a ->search() is in array context since it's my @results =, but is consistent w/my suspicion)
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-19 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found