Perl dbi:fetchrow_array限制结果:

时间:2012-08-31 15:03:22

标签: perl dbi

当我在mySQL Workbench中使用相同的请求时,结果计数为41100。 在我的脚本中,计数是1015.我的代码中没有错误(我使用die来查看它)。 造成这种差异的原因是什么?

# Create the statement 
# select all id in table contacts
$statement = "select distinct contacts.id from $database.contacts"; 

# Prepare and execute the SQL query 
$sqlQuery = $connectGrc->prepare($statement)

# Execute the statement 
$sqlQuery->execute() 

# Make id in array
while($oneId = $sqlQuery->fetchrow_array())
{
    push(@ArrayId,$oneId); 
}

1 个答案:

答案 0 :(得分:2)

没有什么明显的错误(除了缺少错误检查,你的评论不是程序评论)。尝试使用RaiseError连接'use strict;',看看是否存在您可能看不到的问题。此外,如果您想要的只是一列结果,并且可以满足数组引用,请考虑selectcol_arrayref()以方便使用。