最佳实践:在mysql数据库中存储sql语句?

时间:2022-02-28 17:01:12

in most of the free online games now there are always actions needs time to be complete, like for example having to wait for 3 hours for a specific process to complete. I've managed to make a table with a Endofprocess field and with the first interaction with the server the processes that met the time or passed it gets executed.

在大多数免费在线游戏中,现在总是需要时间来完成动作,例如必须等待3个小时才能完成特定的过程。我已经设法创建一个带有Endofprocess字段的表,并且与服务器的第一次交互是满足时间或传递它的进程被执行。

THE QUESTION IS: when the time of the process completion is met, how can I execute a statement like delete or insert or even more than one statement.

问题是:当满足流程完成的时间时,如何执行删除或插入等语句甚至多个语句。

the only thing I'm thinking about is to make another field and store the statement that will be executed upon the task completion.

我唯一想到的是创建另一个字段并存储将在任务完成时执行的语句。

 CREATE  TABLE `dbkorsanx`.`TBLPROCESSES` (
 `ID` INT NOT NULL AUTO_INCREMENT ,
 `PROCESS_ENDS_AT` DATETIME NULL ,
 `PROCESS_STATEMENT` TEXT NULL ,
  PRIMARY KEY (`ID`) );

IS THERE A BETTER IDEA FOR THIS?

这个有更好的想法吗?

1 个解决方案

#1


0  

Instead of saying the query directly, save in the DB what you want to update. It can be a type flag, user_id or someother meta data. If its of variable length save as some json or so

而不是直接说出查询,在数据库中保存要更新的内容。它可以是类型标志,user_id或其他元数据。如果它的可变长度保存为一些json左右

I will have a cron which executes in every n minutes or a service. Based on your logic, the service/script can ran the required queries.

我将有一个每n分钟或服务执行一次的cron。根据您的逻辑,服务/脚本可以运行所需的查询。

#1


0  

Instead of saying the query directly, save in the DB what you want to update. It can be a type flag, user_id or someother meta data. If its of variable length save as some json or so

而不是直接说出查询,在数据库中保存要更新的内容。它可以是类型标志,user_id或其他元数据。如果它的可变长度保存为一些json左右

I will have a cron which executes in every n minutes or a service. Based on your logic, the service/script can ran the required queries.

我将有一个每n分钟或服务执行一次的cron。根据您的逻辑,服务/脚本可以运行所需的查询。