doureng5668 2016-09-01 07:58
浏览 32

如果达到截止日期,laravel php会更新数据库中的所有行吗?

How to update all records in a column every minute?

I have this example:

I borrowed a book at(9/1/2016) and the deadline of my borrowed book is on (9/2/2016), when the deadline has passed and i still didn't return the book after 1 week ill have a total penalty of 7 points. 1 point per day for not returning a book.

For example today is 9/4/2016 my total penalty points is 2 points

borroweddate| deadline | penalty
------      | ------   |---------
9/1/2016    | 9/2/2016 |    2

It's hard to explain sorry please help me.

  • 写回答

1条回答 默认 最新

  • dongyi5570 2016-09-01 08:26
    关注

    You can use cron to run your command/script. If you want to schedule your command minutely you can use:

    * * * * * php /path/to/your/scriptcommand >> /dev/null 2>&1
    

    For laravel apps you can use laravel task scheduling, but you still need cron to run your command. You can use laravel scheduling minutely with this:

        $schedule->call(function () {
            DB::table('your_table')->update(['table_field' => 'some_value' ]);
        })->everyMinute();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号