0

当我在 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); 
}
4

1 回答 1

2

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

于 2012-08-31T15:13:46.617 回答