1: | <?php
2: | namespace Opencart\Catalog\Model\Report;
3: | /**
4: | * Class Statistics
5: | *
6: | * @package Opencart\Catalog\Model\Report
7: | */
8: | class Statistics extends \Opencart\System\Engine\Model {
9: | /**
10: | * Get Statistics
11: | *
12: | * @return array<int, array<string, mixed>>
13: | */
14: | public function getStatistics(): array {
15: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "statistics`");
16: |
17: | return $query->rows;
18: | }
19: |
20: | /**
21: | * Get Value
22: | *
23: | * @param string $code
24: | *
25: | * @return float
26: | */
27: | public function getValue(string $code): float {
28: | $query = $this->db->query("SELECT `value` FROM `" . DB_PREFIX . "statistics` WHERE `code` = '" . $this->db->escape($code) . "'");
29: |
30: | if ($query->num_rows) {
31: | return $query->row['value'];
32: | } else {
33: | return 0;
34: | }
35: | }
36: |
37: | /**
38: | * Add Value
39: | *
40: | * @param string $code
41: | * @param float $value
42: | *
43: | * @return void
44: | */
45: | public function addValue(string $code, float $value): void {
46: | $this->db->query("UPDATE `" . DB_PREFIX . "statistics` SET `value` = (`value` + '" . (float)$value . "') WHERE `code` = '" . $this->db->escape($code) . "'");
47: | }
48: |
49: | /**
50: | * Remove Value
51: | *
52: | * @param string $code
53: | * @param float $value
54: | *
55: | * @return void
56: | */
57: | public function removeValue(string $code, float $value): void {
58: | $this->db->query("UPDATE `" . DB_PREFIX . "statistics` SET `value` = (`value` - '" . (float)$value . "') WHERE `code` = '" . $this->db->escape($code) . "'");
59: | }
60: |
61: | /**
62: | * Edit Value
63: | *
64: | * @param string $code
65: | * @param float $value
66: | *
67: | * @return void
68: | */
69: | public function editValue(string $code, float $value): void {
70: | $this->db->query("UPDATE `" . DB_PREFIX . "statistics` SET `value` = '" . (float)$value . "' WHERE `code` = '" . $this->db->escape($code) . "'");
71: | }
72: | }
73: |

OpenCart API API documentation generated by ApiGen dev-master