Advertisement

01.11.2008 at 12:05PM PST, ID: 23076788
[x]
Attachment Details

Query column names/vaues using Perl/MySQL

Asked by marcparillo in Perl Programming Language

Tags: Perl

I need to query a database and create an associative array of column names and their values from a particular row of a table

$get = $dbh->prepare("SELECT * from mytable where user_id = ?");
$get->execute($user_id);

So, from that one row of the table, I need to return a hash array with column_name => column_value.  

column 1 => column 1 value
column 2 => column 2 value
column 3 => column 3 value

I've seen lots of examples of how to extract just column names or the data from the entire table into a hash array, but I'm looking for something that returns the column names and just the results of one row.  I can do this in PHP, but I can't figure out how to do it with Perl.
Thanks for any guidance!


Start Free Trial
[+][-]01.11.2008 at 12:19PM PST, ID: 20639911

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.11.2008 at 12:34PM PST, ID: 20640070

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.11.2008 at 12:56PM PST, ID: 20640337

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: Perl
Sign Up Now!
Solution Provided By: Adam314
Participating Experts: 1
Solution Grade: A
 
 
[+][-]01.11.2008 at 12:57PM PST, ID: 20640351

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628