2012-08-31 53 views
0

當我在mySQL Workbench中使用相同的請求時,結果的計數是41100. 在我的腳本中,count是1015.我的代碼沒有錯誤(我使用die來查看它)。 這種差異的原因是什麼?Perl dbi:fetchrow_array限制結果:

# 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); 
} 

回答

2

沒有什麼明顯的錯誤(除了沒有錯誤檢查,並且你的評論不是程序評論)。嘗試使用RaiseError連接,'嚴格使用',並查看是否有問題,否則您可能看不到。另外,如果你想要的只是一列結果數組,並且可以解決數組引用問題,爲方便起見,請考慮selectcol_arrayref()。

+1

沒有什麼明顯的錯誤?它甚至沒有編譯!誰知道他的實際代碼是什麼樣的。 – ikegami