1: | <?php
2: | namespace Opencart\Catalog\Model\Tool;
3: | /**
4: | * Class Upload
5: | *
6: | * @package Opencart\Catalog\Model\Tool
7: | */
8: | class Upload extends \Opencart\System\Engine\Model {
9: | /**
10: | * Add Upload
11: | *
12: | * @param string $name
13: | * @param string $filename
14: | *
15: | * @return string
16: | */
17: | public function addUpload(string $name, string $filename): string {
18: | $code = oc_token(32);
19: |
20: | $this->db->query("INSERT INTO `" . DB_PREFIX . "upload` SET `name` = '" . $this->db->escape($name) . "', `filename` = '" . $this->db->escape($filename) . "', `code` = '" . $this->db->escape($code) . "', `date_added` = NOW()");
21: |
22: | return $code;
23: | }
24: |
25: | /**
26: | * Get Upload By Code
27: | *
28: | * @param string $code
29: | *
30: | * @return array<string, mixed>
31: | */
32: | public function getUploadByCode(string $code): array {
33: | $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "upload` WHERE `code` = '" . $this->db->escape($code) . "'");
34: |
35: | return $query->row;
36: | }
37: | }
38: |

OpenCart API API documentation generated by ApiGen dev-master