How to store Birthdate and Age so that Age can be updated daily in PHP/MySQL?

后端 未结 5 1080
天命终不由人
天命终不由人 2020-12-03 06:32

How should I store Birthdate\'s in MySQL so that I can easily update everyone\'s Age on a daily basis via a Cron Job?

Does it even make sense to sto

5条回答
  •  鱼传尺愫
    2020-12-03 06:37

    Im going to go against the majority all of the answers here.

    I would store both ...

    • updating the age is quick and simple - a single mysql query could run every day and its done
    • calculating the age is time consuming when you have lots of page views - amount of times its viewed far outweighs the number of changes

    Just imagine a table scenario - a table with 100 or 1000 rows that shows the age of a person ... how long is that going to take to compute ???

    I always thought that Stackoverflow calculated the Reputation dynamically but you can see on the Stackoverflow data explorer that they dont - see the User object in the schema on the right. Its recorded and updated each time its changed - I would guess that this is purely because of the amount of times its viewed far outweighs the number of changes

提交回复
热议问题