PHP json decode 'attributes' column (EXAMPLE)

jaimzj8 years ago

If you want to find out the last or latest Ignition value for example, then first we use MySQL query to query the DB by joining position records for all device using last positionId.

Then json decode attributes column, you can replace ignition with any other value available in your attributes data including sensor data.

//Query All device, Last Position using positionId from device table (Join query)
//Last Ignition Status
$sql = mysql_query("SELECT * FROM device JOIN position ON position.id=device.positionId");
$row = @mysql_fetch_assoc($sql);  

//Json decode attributes column
$obj = json_decode($row['attributes']);

//output ignition value
echo $obj->{'ignition'};
mtrntx8 years ago

nefertiti can you share a example how to create a user from php?

adirahman6 years ago

cant wok