I'm setting up a caching system in PHP for database queries.
So when a query like "SELECT * FROM table" is called, it either returns the cached results of that query or the results directly from the DB.
$query = "SELECT * FROM table";
[...]
$data = mysql_query($query);
[...]
fwrite($file,json_encode($data));
[...]
The problem is I'm trying to save the query results to a file and I can't find a textual format that works. I've tried json_encode and serialize, and they both return null or 0. Is there a format that will work for this without having to do mysql_fetch_array() and then serialize?
This is the error I get with json, obviously because I haven't converted the result to an array:
Warning: [json] (php_json_encode) type is unsupported, encoded as null