Maybe everyone is still relatively new to PHP time stamp, and today we have an example to explain the specific use PHP timestamps, and application of PHP which will give us the actual time stamp benefits.
We will encounter such a situation: Bank A and Bank B is almost the same time to open your account and see your account on the original 1,000 yuan deposit, then the two banks want in your deposit account with 500.So, put 1,000 into a bank A 1,500 yuan, while Bank B will also be changed to 1,500 yuan 1,000 yuan.So bad! Finally, the last of your bank account instead of only 1,500 yuan should be a 2,000 yuan, equivalent to losing 500 yuan! This is the case in the absence of data to modify the lock caused serious problems.However, we cleverly by PHP timestamp to solve this problem.
We look at ideas:
Create a table in the bank account PHP timestamp field timestamp, set to text type varchar.
When the bank account statement read A deposit field, but also read the timestamp field, such as 123456.
When the value of bank deposits, after modifying A, the save operation, the previously read timestamp 123456 and then table a PHP timestamp comparison, if agreed, then allowed to save, and then generate a new time stamp such as 456789Replace any original timestamp table 123456.
What good this will do.
We look at the beginning of that case: Bank A and Bank B is almost the same time to open your account and see your account on the original 1,000 yuan deposits, the banking sector while at the same time both to read the timestamp 123456, next todifferentiated, when banks A 1,500 yuan to 1,000 yuan after the change, save, than the previous system will save the timestamp 123456 whether the timestamp in the table the same time, obviously, it should be consistent, then allowed to save, andgenerate a new timestamp 456789 123456 replaces the old stamp.Next, B Bank will also become a 1,500 yuan 1,000 yuan changes, save, the system than the previous time stamp is 123456 and save the timestamp in the table the same time, timestamp 123456 has been found in previous and present different timestamp 456789, the system refused to save, refresh the data requested, the data has been refreshed for 1000 yuan into the bank before the A from 500 to 1,500 yuan, then the bank will be in B on the basis of 1,500 yuan to 2,000 yuan, save again,system allows.Thus, we modify the data to avoid duplication caused by mistake!
Some like the tongue twister, I hope you have understand what I mean ~
Finally, let us look at some of the operations timestamp PHP code.
Get time stamp
Update timestamp of the SQL statement:
update table set field name = $ timestamp where condition = value;