1: | <?php
2: | namespace Opencart\Catalog\Model\Setting;
3: | /**
4: | * Class Cron
5: | *
6: | * @package Opencart\Catalog\Model\Setting
7: | */
8: | class Cron extends \Opencart\System\Engine\Model {
9: | /**
10: | * Edit Cron
11: | *
12: | * @param int $cron_id
13: | *
14: | * @return void
15: | */
16: | public function editCron(int $cron_id): void {
17: | $this->db->query("UPDATE `" . DB_PREFIX . "cron` SET `date_modified` = NOW() WHERE `cron_id` = '" . (int)$cron_id . "'");
18: | }
19: |
20: | /**
21: | * Edit Status
22: | *
23: | * @param int $cron_id
24: | * @param bool $status
25: | *
26: | * @return void
27: | */
28: | public function editStatus(int $cron_id, bool $status): void {
29: | $this->db->query("UPDATE `" . DB_PREFIX . "cron` SET `status` = '" . (bool)$status . "' WHERE `cron_id` = '" . (int)$cron_id . "'");
30: | }
31: |
32: | /**
33: | * Get Cron
34: | *
35: | * @param int $cron_id
36: | *
37: | * @return array<string, mixed>
38: | */
39: | public function getCron(int $cron_id): array {
40: | $query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "cron` WHERE `cron_id` = '" . (int)$cron_id . "'");
41: |
42: | return $query->row;
43: | }
44: |
45: | /**
46: | * Get Cron By Code
47: | *
48: | * @param string $code
49: | *
50: | * @return array<string, mixed>
51: | */
52: | public function getCronByCode(string $code): array {
53: | $query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "cron` WHERE `code` = '" . $this->db->escape($code) . "' LIMIT 1");
54: |
55: | return $query->row;
56: | }
57: |
58: | /**
59: | * Get Cron(s)
60: | *
61: | * @return array<int, array<string, mixed>>
62: | */
63: | public function getCrons(): array {
64: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "cron` ORDER BY `date_modified` DESC");
65: |
66: | return $query->rows;
67: | }
68: |
69: | /**
70: | * Get Total Cron(s)
71: | *
72: | * @return int
73: | */
74: | public function getTotalCrons(): int {
75: | $query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "cron`");
76: |
77: | return (int)$query->row['total'];
78: | }
79: | }
80: |

OpenCart API API documentation generated by ApiGen dev-master