I have the below sql query.. in which I'm mapping the contents to a kendo front-end table..
$sql = "SELECT big_id, fac_ident, lg_name, basic_tp, catc_vd, address, assoc_city, latitude, longitude, assoc_cnty, assoc_st, time_zone, faa_reg, ato_sa, ato_td, fema_reg, ops_hrs, prim_ph, atc_level, tower_type, manager, sat_phone_num, td_mgr, to_dist, tod_mgr, stof_fac, ops_status, crt_rl FROM myCoolApp.big_id";
The problem is.. columns that are not finding any associated value in the DB, is not returning any value back, and alas just completely omitted from the response array.. i.e. in ops_hrs
above no value is found, so it's completely omitted from my array - I need it to still exist, just be blank.
I would like the response to still display the column in the array even when it's value is empty; ideally just adding a blank space " "
or 'N/A'
even. As I do not want the null column to be dropped in my array and front-end.
The rest of my PHP/sql...
$stid = oci_parse($this->db, $sql);
oci_execute($stid);
$myData = array();
while ($list = oci_fetch_array($stid, OCI_ASSOC)) {
array_push($myData, $list);
}
header('Content-Type: application/json');
echo "{\"data\":" .json_encode($myData). "}";
What am I missing here? I need to handle it programmatically with PHP/sql.
Use OCI_RETURN_NULLS
:
while ($list = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
array_push($myData, $list);
}