【问题标题】:How can I create event and run it every day at 00:00:00 in MySQL Workbench?如何在 MySQL Workbench 中每天 00:00:00 创建事件并运行它?
【发布时间】:2017-03-05 18:03:56
【问题描述】:

当我使用 cakephp 和 MySQL Workbench 进行项目时,我的数据库出现问题。我有一张这样的桌子:

<table style="with:100%">
  <tr>
    <th>id</th>
    <th>remind</th> 
    <th>status</th>
    <th>created</th>
  </tr>
  <tr>
    <td>1</td>
    <td>do excersice</td> 
    <td>1</td>
    <td>2017-03-04 09:56:56</td>
  </tr>
  <tr>
    <td>2</td>
    <td>read a book</td>
    <td>1</td>
    <td>2017-03-04 09:56:56</td>
  </tr>
</table>

我希望每天,数据库中 'DATE(created)' => date('Y-m-d', strtotime("-1 days")) 的所有记录都将在新的一天 00:00:00 自动插入.我在 2017-03-05 的桌子看起来像

<table style="with:100%">
  <tr>
    <th>id</th>
    <th>remind</th> 
    <th>status</th>
    <th>created</th>
  </tr>
  <tr>
    <td>1</td>
    <td>do excersice</td> 
    <td>1</td>
    <td>2017-03-04 09:56:56</td>
  </tr>
  <tr>
    <td>2</td>
    <td>read a book</td>
    <td>1</td>
    <td>2017-03-04 09:56:56</td>
  </tr>
  <tr>
    <td>3</td>
    <td>do excersice</td> 
    <td>0</td>
    <td>2017-03-05 00:00:00</td>
  </tr>
  <tr>
    <td>4</td>
    <td>read a book</td>
    <td>0</td>
    <td>2017-03-05 00:00:00</td>
  </tr>
</table>

当然,status 字段会变为 0。我将在今天的其他操作中更新字段。 Countinue,2017-03-06 将从创建的记录中获得价值 = 2017-03-05。

【问题讨论】:

标签: mysql-workbench cakephp-3.0


【解决方案1】:

在 MySQL Workbench 中无法定期自动运行命令。通常 GUI 工具不适用于此类后台任务,因为它们需要活动窗口站(桌面或在特定操作系统中的命名方式)。但是,您可以做的是在您的数据库中 create an event 并让它更新您的表。

【讨论】:

    猜你喜欢
    • 2021-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多