douchuanchai2793 2015-07-16 18:59
浏览 73
已采纳

事务中数据库查询的时间戳

I'm using DB::transaction and SoftDeletes.

For those unfamiliar with Laravel the SoftDelete functionality of Laravel abstracts away the setting / querying of rows in the database. When a record is deleted the field deleted_at is given a timestamp otherwise this field is null. This field is then used on querying to only get non deleted rows.

Currently I have a script that runs every day that deletes all the soft deleted entries that are older than 7 days.

enter image description here This is where my question/problem is. What if my DB::transaction spanned for let's say 10 seconds and add the end writes to Table A and Table B so that the entries in both tables have a different timestamp.

I can picture a scenario where when the cleanup script executes it could delete HALF of the entry records.

My question then is

  1. would a DB::transaction give the same timestamp to all the records?
  2. if not how can I remedy this problem?
  • 写回答

1条回答 默认 最新

  • dts777777 2015-07-16 19:26
    关注

    The only way I can seeing it working, as it seems mission critical that your data isn't messed up with a partial restore as you say, is to include a transaction number in your affected tables.

    The cleanup routine would need to be tweaked. A transaction cannot be soft deleted and subsequently wiped unless all the timestamps in the transaction exceed 7 days.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?