This is strange, but in the following script my SELECT statement successfully retrieves the 11 rows I expect AND the JSON file is written at the end of the script. However, the JSON is totally empty.
So I know my select works and retrieves what I need and I know the process for writing/saving the JSON works but I feel like I'm somehow misusing my arrays and the odbc_fetch_array function. I've never used that process before (odbc_fetch_array) and it looks like I'm doing what the documentation instructs.
Is there a reason why the array portion here doesn't seem to work properly to keep the data housed and write it to the JSON?
$selectForJSON =
"SELECT
ext_id,
extension,
total_talk_time_seconds,
total_talk_time_minutes,
total_inbound,
total_outbound,
credit_for_outbound,
missed_calls,
total_calls,
percent_answered,
dealers_contacted,
percent_up_to_date,
date_of_report,
time_of_report
FROM daily_totals
WHERE Date_of_report >= curdate()";
$prepJSONSelect = odbc_prepare($DB2Conn, $selectForJSON);
$executeJSON = odbc_execute($prepJSONSelect);
//new array specifically for the final JSON file
$content2 = [];
//creating array for new fetch since it now has the updated extension IDs
while ($d2 = odbc_fetch_array($executeJSON)) {
$content2[] = $d2;
}
// Store it all into our final JSON file
file_put_contents('LogTest.json', json_encode($content2, JSON_PRETTY_PRINT ));