How do I perform an insert in php where the data is passed by a json that has a non-primitive variable in the object.
This is my Json
{"id":0,"latitude":-8.0326941,"longitude":-34.9287402,"status":1,
"tipovaga":{"descricao":"no aplication","id":5},
"usuario":"email":"[email protected]","id":14,"nome":"nome","palavrasecreta":"secreto","password":"XXXX"}
}
This is webservice
$stmt = $conn->prepare("INSERT INTO flanelinha_db.HistoricoVaga (tipo_vaga,usuario, latitude, longitude, status, endereco, bairro, cidade, estado) VALUES (?,?,?,?,? , null,null,null,null)");
$json = json_decode(include("novavaga.json"));
$tipovaga = $json ->{'tipovaga'};
$usuario = $json->{'usuario'};
$latitude = $json->{'latitude'};
$longitude = $json->{'longitude'};
$status = $json->{'status'};
$stmt->bind_param("iiddi", $tipovaga, $usuario, $latitude, $longitude ,$status);
$stmt->execute();
$stmt->close();
$id = $conn->insert_id;
I need to write the id of the type of PK and user type in the database.