Back to Opencart

File catalog\model\account\api.php

docs/api/source-catalog.model.account.api.html

4.1.0.35.7 KB
Original Source

Namespaces

Classes

| 1: | <?php | | 2: | namespace Opencart\Catalog\Model\Account; | | 3: | /** | | 4: | * Class Api | | 5: | * | | 6: | * @package Opencart\Catalog\Model\Account | | 7: | */ | | 8: | class Api extends \Opencart\System\Engine\Model { | | 9: | /** | | 10: | * Login | | 11: | * | | 12: | * @param string $username | | 13: | * @param string $key | | 14: | * | | 15: | * @return array<string, mixed> | | 16: | */ | | 17: | public function login(string $username, string $key): array { | | 18: | $query = $this->db->query("SELECT * FROM " . DB\_PREFIX . "api WHERE username = '" . $this->db->escape($username) . "' AND key = '" . $this->db->escape($key) . "' AND status = '1'"); | | 19: | | | 20: | return $query->row; | | 21: | } | | 22: | | | 23: | /** | | 24: | * Add Session | | 25: | * | | 26: | * @param int $api_id | | 27: | * @param string $session_id | | 28: | * @param string $ip | | 29: | * | | 30: | * @return int | | 31: | */ | | 32: | public function addSession(int $api_id, string $session_id, string $ip): int { | | 33: | $this->db->query("INSERT INTO " . DB\_PREFIX . "api\_session SET api\_id = '" . (int)$api_id . "', session_id = '" . $this->db->escape($session_id) . "', ip = '" . $this->db->escape($ip) . "', date_added = NOW(), date_modified = NOW()"); | | 34: | | | 35: | return $this->db->getLastId(); | | 36: | } | | 37: | | | 38: | /** | | 39: | * Get Ips | | 40: | * | | 41: | * @param int $api_id | | 42: | * | | 43: | * @return array<int, array<string, mixed>> | | 44: | */ | | 45: | public function getIps(int $api_id): array { | | 46: | $query = $this->db->query("SELECT * FROM " . DB\_PREFIX . "api\_ip WHERE api\_id = '" . (int)$api_id . "'"); | | 47: | | | 48: | return $query->rows; | | 49: | } | | 50: | } | | 51: | |

OpenCart API API documentation generated by ApiGen dev-master