I have a model "Model_Tmtrace" which contains has "lat", "lon" among other fields, in order to store gps coordinate data.
I'm getting a json string from a file, and each object in the json string that has the same fields as a Model_Tmtrace....
What is the best way to store the json data into the database?
Should I do a foreach loop and forge and save each individual tmtrace derived from the json data.... or, is there a way to tell fuelphp that the json equates to a model and store everything at once?
And/Or, does it make a difference to call the database multiple times vs one single time with a big query?
If you're doing bulk uploads, from a performance point of view it's better to use DB::Insert() instead of the ORM, it's much faster.
If you have a json string, you can convert it to an assoc array using json_encode(). If the assoc array has the same key names as your table columns, you can use it as input of Model::forge(), or as values() on a DB::insert.