1

I'm trying to store a set of data in a TEXT field in my MySQL database. The data to store are as follow (data format is not fixed yet):

[location1] => (lat,lon,zoom)
[location2] => (lat,lon,zoom)
[location3] => (lat,lon,zoom)
etc...

In the end all these data will be one single string. How should I write/format this string so that I can then use it in PHP as a regular associative array?

4
  • php.net/serialize or php.net/json_encode Commented Mar 28, 2012 at 17:51
  • 1
    Storing formatted data in a database negates the purpose of having the database in the first place. That reduces it to just being a very 'expensive' file storage medium. Create a table that contains location, lat, lon, zoom fields and store each datum in its assigned field. Commented Mar 28, 2012 at 17:52
  • Alright but isn't it a problem if a table ends up with millions of rows? Commented Mar 28, 2012 at 17:57
  • 1
    Well storing the values in a gigantic text field isn't going to alleviate the problem of storing a million rows. Commented Mar 28, 2012 at 19:02

1 Answer 1

2

Why don't you save them in an individual table with this scheme:

Foreign key | Location (text) | lat (double) | lon (double) | zoom (double)

Sign up to request clarification or add additional context in comments.

1 Comment

I could do that but I would prefer not create another table. Plus, I'm interested in the solution to this problem ^^

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.