I want to store twitter raw tweet data that I get when accessing the API in a mysql database. How do I do so? should I just store the data in json format (as it is already)? Should I first json_decode the data and then call serialize? If so, what are the pro/cons? My goal is to protect the integrity and accuracy of the data and to make it fast for me to decode and encode. thanks!
I’m using PHP/Mysql.
Storing the data in the database in the format you intend to use it later is best, that way you only manipulate it once. In terms of integrity, the mysql_real_escape_string and serialize / unserialize functions will ensure what you store is what you get back.
To store the data for retrieval and assuming you have your data (whatever format) in a PHP variable $data, you may do something like.