Помогите пожалуйста! Нужна помощь!
Есть дапустим прописанный код:
%DEL=('01'=>{'server'=>'SUPER',
'host'=>'GOOD'});
А как нужно написать код чтобы он из базы MySQL сохранял для каждого $id --> $name и $data автоматически
...
my%DEL;
my $sth=$dbh->prepare(qq/SELECT `id`,`name`,`data` FROM `$SQL{tab}->{info};/);
$sth->execute;
while(my($id,$name,$data)=($sth->fetchrow_array))
{
@DEL{$id}=$name;# ??????????????? :?:
}
$sth->finish;
...
Заранее Спасибо! :?:
Помощь в создании Hash масивов
while(my($id,$name,$data)=($sth->fetchrow_array))
{
$DEL{$id}={};
$DEL{$id}->{'name'} = $name;
$DEL{$id}->{'data'} = $data;
}
{
$DEL{$id}={};
$DEL{$id}->{'name'} = $name;
$DEL{$id}->{'data'} = $data;
}
Тут читая use MySQL нашел:
%hash = $sth->fetchhash;
return a complete hash. The keys in this hash are the column names of the table, the values are the table values. Be aware, that when you have a table with two identical column names, you will not be able to use this method without trashing one column. In such a case, you should use the fetchrow method.
%hash = $sth->fetchhash;
return a complete hash. The keys in this hash are the column names of the table, the values are the table values. Be aware, that when you have a table with two identical column names, you will not be able to use this method without trashing one column. In such a case, you should use the fetchrow method.