2 messages in com.mysql.lists.perlRe: Auto-populating variables
FromSent OnAttachments
James W. Blackwell29 Aug 1999 15:13 
Richard K. Moore31 Aug 1999 11:58 
Subject:Re: Auto-populating variables
From:Richard K. Moore (rkmo@iol.ie)
Date:08/31/1999 11:58:22 AM
List:com.mysql.lists.perl

8/29/1999, James W. Blackwell wrote:

Is there a simple way to select a row from a table and have variables of the names of the columns populated automagically without having to do a fetchrow_array with all of the variables listed before it.

In a related question, is there a way to do the opposite and have all fields updated with the values held in the variable that represents the column?

>Am I making any sense? Maybe someone could point me >somewhere on the web where I could find more info on this?

It's all in 'perldoc DBI'.

I find the following sufficient for the kind of thing you want:

$hash_ref = $sth->fetchrow_hashref;

but there are also the following:

$rc = $sth->bind_col($col_num, \$col_variable); $rc = $sth->bind_columns(\%attr, @list_of_refs_to_vars_to_bind);

$rv = $sth->bind_param($param_num, $bind_value); $rv = $sth->bind_param($param_num, $bind_value, $bind_type); $rv = $sth->bind_param($param_num, $bind_value, \%attr);

rkm http://cyberjournal.org/quay_largo/