Add methods to manage scheduled tasks

This commit is contained in:
Kijin Sung 2024-12-12 11:25:29 +09:00
parent caf882fed0
commit 5ff2f15485
2 changed files with 52 additions and 0 deletions

View file

@ -190,6 +190,21 @@ class DB implements QueueInterface
}
}
/**
* Get a scheduled task by its task_srl.
*
* @param int $task_srl
* @return ?object
*/
public function getScheduledTask(int $task_srl): ?object
{
$oDB = RFDB::getInstance();
$stmt = $oDB->query('SELECT * FROM task_schedule WHERE task_srl = ?', [$task_srl]);
$task = $stmt->fetchObject();
$stmt->closeCursor();
return $task ?: null;
}
/**
* Get scheduled tasks.
*
@ -270,4 +285,17 @@ class DB implements QueueInterface
$stmt->execute([date('Y-m-d H:i:s'), date('Y-m-d H:i:s'), $task->task_srl]);
}
}
/**
* Cancel a scheduled task.
*
* @param int $task_srl
* @return bool
*/
public function cancelScheduledTask(int $task_srl): bool
{
$oDB = RFDB::getInstance();
$stmt = $oDB->query('DELETE FROM task_schedule WHERE task_srl = ?', [$task_srl]);
return ($stmt && $stmt->rowCount()) ? true : false;
}
}