I'm having some trouble figuring out how to take JSON results from a MySQL query; turn them into a PHP array; remove the identical fields from that array, and turn the array back into JSON. The [1] is the part of the row with the actual JSON in it.
Am I missing something? Having trouble finding any similar questions on the site. Thanks!
$data = mysql_fetch_row($result);
print_r($data);
$json = json_decode($data[1], TRUE);
var_dump($json);
print_r($json);
$distinctresult = array_unique($json);
print_r($distinctresult);
$final = json_encode($distinctresult);
{"rows":[{"level":"ERROR","key":"Standard Not found","value":"RI.1.8"},{"level":"ERROR","key":"Standard Not found",{"level":"ERROR","key":"Standard Not found","value":"RI.K.9"},{"level":"ERROR","key":"Standard Not found","value":"RI.K.9"},{"level":"ERROR","key":"Standard Not found","value":"RI.K.9",}]}
Here's the MySQL query I'm using:
"select distinct d.valueField
from etllogs t
inner join etllogdetails d on t.uid = d.etllogID and d.valueField like '%ERROR%'
where t.transformationName like 'CM Data Extract'
and (t.timestamp >= (now() - interval 24 hour))
order by t.timestamp desc;";