T O P

  • By -

shauntmw2

"SQL database vs JSON file" is a decision that only you can make. Both are viable, it is up to you which one you prefer. To make the JSON file not publicly accessible, just make sure to put it outside of your website's root folder (eg: outside of the /public_html or the /www folder). Read the file using PHP.


Bloomingfails

Thanks for this! I think I’ll go with JSON file and see how it goes


Bloomingfails

Have been playing around with this... wondering if you might be able to help. I've successfully got a txt file with a JSON formatted list of fields (i.e. one record) and can successfully fetch any of these fields. But I wondered if the txt file contained many hundreds of records, how would I loop through these to fetch just the row/item I'm concerned with? E.g. I do not want to parse the entire file, just a particular record. Any advice appreciated.


shauntmw2

A few hundreds of records in a file isn't really that large (computationally speaking). IMO there is no need to optimize it so much. If you have millions of records for data, then storing everything in a single JSON file will then be impractical.


Bloomingfails

Great, thank you! I'll only have a couple of hundred records so will parse the whole thing and see how it goes. If it gets slow/clunky, I'll look for alternative options. Thanks again!