我有一個特殊的mysqli查詢,返回結果集數組中第0個位置的空元素。這個空非對象元件似乎當我在結果設置爲顯示於屏幕mysqli fetch_object在結果集數組的第一個元素中返回非對象
$projAreas[] = array();
$projectID = $_GET['projectID'];
$sql = "SELECT *
FROM `areas` , `project_area_junc`
WHERE `areas`.`areaID` = `project_area_junc`.`areaID`
AND `project_area_junc`.`projectID` = $projectID";
$results = $conn->query($sql);
while($row = $results->fetch_object()) {
$projAreas[] = $row;
}
結果嘗試循環引起問題在位置0給出不期望的數組元素) 即當我的print_r($ projAreas) 我得到這個:
Array
(
[0] => Array
(
)
[1] => stdClass Object
(
[areaID] => 56
[propertyID] => 14
[areaName] => Living Room
[areaInfo] => lots of windows - colonial style
[proj_area_juncID] => 10
[projectID] => 4
)
[2] => stdClass Object
(
[areaID] => 57
[propertyID] => 14
[areaName] => Kitchen
[areaInfo] =>
[proj_area_juncID] => 11
[projectID] => 4
)
感謝,該作品! ,因爲你發現問題是因爲我包括了方括號 - 我應該看到,哦,哦! – mikeC