How to store API JSON response in MYSQL database

I'm using an API that provides the data in JSON format. I'm trying to store the JSON response in the MySQL database (just as it is)

and then refetch it from the database in JSON format. You may be wondering why I'm doing this, well, I'm using a paid API that has limited no. of requests. To prevent multiple API calls, I wanted to serve API responses through my server (So basically application users would be polling my server to fetch the JSON response Instead of directly calling an API)

So I created a table named "matchinfo" and there is a column named "jsondata" which has a type of LONGTEXT

$json_response = file_get_contents("api_url"); // storing json format response

$update_data = "UPDATE matchinfo SET jsondata = '$json_response'"; // Succesfully stored it

$update_query = mysqli_query($conn,$update_data); 


// how can I again fetch it in the JSON format 



from Recent Questions - Stack Overflow https://ift.tt/3rjnGUl
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations