0

please i have a modified_by column in mysql table with string like this "40,1280825613|40,1280825617". the "40" is the id of the user that made changes to the record and "1280825613" is the date string. The | separates different periods of change.

How do i change the entire column to a readable date without affecting the user id. either mysql or php solution is welcome. Thank you so much.

1 Answer 1

1

I'd recommend a PHP script. You'll need to make two columns modified_by to retain the user id and modified for the timestamp. If there are multiple modified_by for each record you'll probably want to make a separate table, i.e. revisions. This would be the best way to store the data relationship. I'd also recommend not storing formatted data. You should already see why that's not a good idea. The database is the raw data, use PHP to format it.

Once you have that setup, just:

  1. Select the data from the old table.
  2. Loop over the records
  3. explode() the column on |
  4. Loop over the array
  5. explode() the element on ,
  6. Insert into new columns/table

Forgive me, but I'd rather teach you how to fish.

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

1 Comment

wow, thats super fast. thank you for the suggestion. will try that pending other suggestion. thank you once again

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.