2013-11-25 88 views
0

我正在運行以下查詢,其中包含兩個長文本字段(175 & 525),並且出現錯誤內存不足。這個查詢已經太長了,或者是其他事情發生了嗎?PHP/SQL內存不足:致命錯誤:內存不足(分配爲1310720)(試圖分配4294967296字節)

錯誤:致命錯誤:內存(分配1310720)(試圖分配4294967296個字節)

$query = "SELECT username, url, accountcreated, accountstatus, address, city, birthday, education, relation, gender, profile_story, intsettinga, intsettingb FROM users WHERE username=?"; 

$stmt = $db->stmt_init(); 
($stmt->prepare($query))|| fail('An error occurred: MySQL prepare', $db->error); 
$stmt->bind_param("s",$username)|| fail('An error occurred: MySQL bind_param', $db->error); 
$stmt->execute()|| fail('An error occurred: MySQL execute', $db->error); 
$stmt->bind_result($screenname, $url, $created, $status, $address, $city, $bday, $education, $relation, $gender, $profile, $settinga, $ssettingb)|| fail('An error occurred: MySQL bind_result', $db->error); 
$stmt->fetch() || fail('Profile not found'); 
$stmt->close(); 
$db->close(); 
+0

你有多少記錄在表中? – Jerielle

+0

現在只有3條記錄 – Diego

+0

這有點奇怪,我需要4GB的內存,或者是不是什麼試圖分配4294967296字節的手段在這個消息 – Diego

回答

0

錯誤是在bind_result,加入stmt- $> store_result();解決它:

$stmt->execute()|| fail('An error occurred: MySQL execute', $db->error); 

$stmt->store_result(); 

$stmt->bind_result($screenname, $url, $created, $status, $address, $city, $bday, $education, $relation, $gender, $profile, $settinga, $ssettingb)|| fail('An error occurred: MySQL bind_result', $db->error); 
$stmt->fetch() || fail('Profile not found'); 
$stmt->close(); 
$db->close(); 
相關問題