1 回答

TA貢獻(xiàn)1824條經(jīng)驗 獲得超5個贊
您收到此錯誤/警告是因為您正在pg_fetch_object()通話pg_prepare()。本質(zhì)上,每次在while()循環(huán)中迭代時,您都會再次調(diào)用pg_prepare(),無意中嘗試創(chuàng)建一個新的準(zhǔn)備好的語句,稱為“停車”。
您真正要做的是獲得結(jié)果,pg_execute()然后使用以下方法提取結(jié)果pg_fetch_object():
$devices_query = pg_query($conn, "SELECT applications.name category, devices.* FROM app_as.application applications, app_as.device devices WHERE applications.id = devices.application_id");
$prepare_result = pg_prepare($conn, "parking", "SELECT distinct on (name) name,application_name,longitude,latitude,parking_car_status status,received_at FROM V_DEVICE_PARKING WHERE name = $1");
// Maybe process $prepare_result as needed here
while ($devices = pg_fetch_object($devices_query)) {
$execute_result = pg_execute($conn, "parking", [$devices->name]);
while ($parking = pg_fetch_object($execute_result)) {
$devices->parking_car_status = $parking->parking_car_status;
}
$data['DEVICES'][] = $devices;
}
- 1 回答
- 0 關(guān)注
- 134 瀏覽
添加回答
舉報