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