tjyoung
asked on
Before I get too far.. best way to save dates data
Hi,
I am keeping a record of days a store is closed for the year ie:
2017-01-01
2017-01-03
2017-01-04
2017-01-09
So I'm using multi-datepicker which allows me to select closed days for the year, and inserts them into a hidden text field to include along with the rest of my form's POST submission.
Like this: 2017-01-01,2017-01-03,2017 -01-04,201 7-01-09 etc.
Was thinking I'd use 'explode' and insert each into the DB separately into a date column and dealer_id.
Then I began to wonder wouldn't I be better off to simply insert the values as an 'array' something like this into a single record for the year ie:
closed: ["2017-01-01","2017-01-03" ,"2017-01- 04","2017- 01-09"]
dealer_id: XXXXXX
Going forward I'd be checking the table daily to see if the above 'array' contains todays date in case they are closed.
So my question is:
What is the best way to store that kind of data? As a comma-separated string or a separate entry per date?
I am keeping a record of days a store is closed for the year ie:
2017-01-01
2017-01-03
2017-01-04
2017-01-09
So I'm using multi-datepicker which allows me to select closed days for the year, and inserts them into a hidden text field to include along with the rest of my form's POST submission.
Like this: 2017-01-01,2017-01-03,2017
Was thinking I'd use 'explode' and insert each into the DB separately into a date column and dealer_id.
Then I began to wonder wouldn't I be better off to simply insert the values as an 'array' something like this into a single record for the year ie:
closed: ["2017-01-01","2017-01-03"
dealer_id: XXXXXX
Going forward I'd be checking the table daily to see if the above 'array' contains todays date in case they are closed.
So my question is:
What is the best way to store that kind of data? As a comma-separated string or a separate entry per date?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great article and very relevant. Thanks again.
Glad to help! All the best for 2017, ~Ray
For these configuration values I create a Config table, each record has Key and Value and I would just save it as JSON to the Value table with Key of "Closed" or whatever.
Open in new window
I am sure there are better approaches