我正在尝试获取像(Select 1 from table)这样的数据,它返回一行一列的数据.
我不想使用$sth->fetchrow_array方法将数据检索到数组.有没有办法将数据收集到标量变量direclty?
fetchrow_array返回一个列表 - 不可能返回一个数组 - 你可以将它分配给任何列表 -比如a my().
my $sth = $dbh->prepare($stmt);
$sth->execute();
my ($var) = $sth->fetchrow_array()
and $sth->finish();
Run Code Online (Sandbox Code Playgroud)
或者你可以简单地使用
my ($var) = $dbh->selectrow_array($stmt);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14534 次 |
| 最近记录: |