-1
我想從數據庫mysql中只讀取和打印一條記錄。Select語句應該只返回一條記錄
#Select backlogs
{
my $backlog_req = "select id, name, startDate, endDate, parent_id " .
" from backlogs " ;
"where backlogtype='Iteration' and id = $iteration" ;
print "ITERATION_ID : " . $iteration . "\n";
my $sth = $dbh->prepare($backlog_req);
$sth->execute() ;
$sth->bind_columns(undef, \$backlog_id, \$bl_name, \$bl_sd, \$bl_ed, \$prod_id) ;
while($sth->fetch()) {
$Backlogs->{ $backlog_id } = { name => $bl_name, start_date => substr($bl_sd, 0, 10), end_date => substr($bl_ed, 0, 10) } ;
print "$bl_name ($backlog_id): $bl_sd -> $bl_ed\n";
}
這將返回所有與Iteration作爲backlogtype的行。我只需要backlogtype作爲Iteration和Id,我通過命令行參數提供。正如我在哪裏指定的那樣。