What is the easiest way to recover data from a database, and convert data into JSON string? Is any kind of assistant class? Or am I loop through columns in my dataset to make JSON string?
The sample code would be great
You get a basic PHP array or stdClass
The object can use the function to represent the JSON:
$ result = $ dB-> Query ('some search'); $ Set = array (); If ($ result- & gt; num_rows) {while ($ line = $ result-> fetch_array ()) {$ set [] = $ row; }} Echo json_encode ($ set);
Comments
Post a Comment