PHP を介して SQL クエリを呼び出すときに、「許容メモリ サイズ ... バイトが使い果たされました」という問題が発生しています。どういうわけか、配列の作成者がループに陥っていると思います。
私のphp:
<?php
function confirm_query($result_set) {
if (!$result_set) {
die("DB query fail: " . mysql_error());
}
}
$con = mysql_connect("mysql15.000webhost.com", "***_mw", "***");
if (!$con) {
die("DB connect fail: " . mysql_error());
}
$mySqlDB = "a9414387_build";
$dbSelect = mysql_select_db($mySqlDB, $con);
if (!$dbSelect) {
die("db select fail: " . mysql_error());
}
$sku = $_POST['serching'];
$query = "SELECT * FROM inventory1 WHERE id LIKE '{$sku}%'";
$result = mysql_query($query, $con);
$des = mysql_fetch_array($result);
$matches = mysql_num_rows($result);
$json = array();
if ($matches > 0) {
while($des) {
$bus = array(
'description' => $des['description'],
'price' => $des['price'],
'sku' => $des['id'],
'type' => $des['type'],
);
$jsonString = array_push($json, $bus);
}
echo json_encode($jsonString);
} else {
echo json_encode(NULL);
}
die();
?>
しかし、私がコメントアウトした場合:
while($des) {
$bus = array(
'description' => $des['description'],
'price' => $des['price'],
'sku' => $des['id'],
'type' => $des['type'],
);
$jsonString = array_push($json, $bus);
}
$jasonString を $des に置き換えます。次のような結果が得られます。
{"0":"4040284","id":"4040284","1":"F","active":"F","2":"T","defaults":"T","3":"aurora,superNova","model":"aurora,superNova","4":null,"defmodel":null,"5":"mboard","type":"mboard","6":"105","price":"105","7":"Intel H67 (1155) Motherboard","description":"Intel H67 (1155) Motherboard","8":"1155","socket":"1155","9":"Not available at this time.","infoDiv":"Not available at this time.","10":"IntelH67Socket1155Motherboard.jpg","image":"IntelH67Socket1155Motherboard.jpg"}
私はメモリサイズを拡張するつもりはありません。b/c 1 つの小さな配列をこれほど大きくすべきではありません。