У меня есть главный запрос, я получаю данные из запроса и показываю их в форме JSON.Теперь главный запрос имеет несколько строк во второй таблице, которые являются дочерними строками с внешним ключом.Мои данные основного запроса показывают правильный JSON с объектом, но я не могу объединить оба с одним индексом
{
"0": [
{
"FILE_PATH": "IMG_20190917_11224674.jpg"
},
{
"FILE_PATH": "IMG_20190917_11122730.jpg"
},
{
"FILE_PATH": "20190917_110327.mp4"
},
{
"FILE_PATH": "IMG-20190920-WA0006.jpg"
},
{
"FILE_PATH": "20190917_110322150_cf27153e9a2370154223da9c3490e109.mp4"
}
],
"Result": [
{
"INC_ID": "8",
"INC_NAME": "google map",
"INC_LOCATION": "Plot 55 K, Block K Model Town, Lahore, Punjab, Pakistan",
"INC_CATEGORY": "Near Miss",
"INC_LAT": "31.4842451",
"INC_LONG": "74.3135311",
"INC_DATE": "23-SEP-19 05.36.45.000000 PM",
"UNIT_CODE": "1",
"INC_REMARKS": "nfjfrjxi",
"INC_ACTION": "Pending",
"CREATED_BY": "rashid.hanif@sgroup.pk",
"UPDATE_BY": null,
"LOC_ID": "1",
"INC_DATE_FORM": "23-09-19 05:09:45 PM"
},
{
"INC_ID": "7",
"INC_NAME": "testing for new versuon ",
"INC_LOCATION": "Plot 102K, Block K Model Town, Lahore, Punjab, Pakistan",
"INC_CATEGORY": "Injury",
"INC_LAT": "0",
"INC_LONG": "0",
"INC_DATE": "23-SEP-19 05.34.37.000000 PM",
"UNIT_CODE": "41",
"INC_REMARKS": " this",
"INC_ACTION": "Pending",
"CREATED_BY": "rashid",
"UPDATE_BY": null,
"LOC_ID": "4",
"INC_DATE_FORM": "23-09-19 05:09:37 PM"
},
<?php
include 'connection.php';
$details = array();
$details1 = array();
$UNIT_CODE=$_REQUEST["UNIT_CODE"];
$query=oci_parse($c,"select a.* , TO_CHAR(INC_DATE,'dd-mm-yy hh:mm:ss AM' ) as INC_DATE_FORM from hss_incidents a where a.UNIT_CODE IN ($UNIT_CODE) ORDER BY INC_DATE DESC
");
$response = oci_execute($query);
$B = oci_num_rows($query);
if($B >= 0){
while ($row = oci_fetch_array($query, OCI_ASSOC + OCI_RETURN_NULLS)) {
$details[] = $row;
$ABC=$row['INC_ID'];
$query1=oci_parse($c,"select FILE_PATH
from
hss_incidents a, hss_location b, hss_files c
where a.LOC_ID=B.LOC_ID
AND a.INC_ID='$ABC'
");
$response1 = oci_execute($query1);
while ($row1 = oci_fetch_array($query1, OCI_ASSOC + OCI_RETURN_NULLS)) {
$details1[] = $row1;
}
}
echo json_encode(array("Result"=>$details,$details1));
}
else{
echo "No Data Found";
}
?>
Ожидаемый результат:
"Result": [
{
"INC_ID": "8",
"INC_NAME": "google map",
"INC_LOCATION": "Plot 55 K, Block K Model Town, Lahore, Punjab, Pakistan",
"INC_CATEGORY": "Near Miss",
"INC_LAT": "31.4842451",
"INC_LONG": "74.3135311",
"INC_DATE": "23-SEP-19 05.36.45.000000 PM",
"UNIT_CODE": "1",
"INC_REMARKS": "nfjfrjxi",
"INC_ACTION": "Pending",
"CREATED_BY": "rashid.hanif@sgroup.pk",
"UPDATE_BY": null,
"LOC_ID": "1",
"INC_DATE_FORM": "23-09-19 05:09:45 PM"
}, "Images"[ {
"FILE_PATH": "IMG_20190917_11224674.jpg"
},
{
"FILE_PATH": "IMG_20190917_11122730.jpg"
},
{
"FILE_PATH": "20190917_110327.mp4"
}]
]