Back to Opencart

File admin\model\tool\backup.php

docs/api/source-admin.model.tool.backup.html

4.1.0.34.8 KB
Original Source

Namespaces

Classes

| 1: | <?php | | 2: | namespace Opencart\Admin\Model\Tool; | | 3: | /** | | 4: | * Class Backup | | 5: | * | | 6: | * @package Opencart\Admin\Model\Tool | | 7: | */ | | 8: | class Backup extends \Opencart\System\Engine\Model { | | 9: | /** | | 10: | * Get Tables | | 11: | * | | 12: | * @return array<int, string> | | 13: | */ | | 14: | public function getTables(): array { | | 15: | $table_data = []; | | 16: | | | 17: | $query = $this->db->query("SHOW TABLES FROM " . DB\_DATABASE . ""); | | 18: | | | 19: | foreach ($query->rows as $result) { | | 20: | if (isset($result['Tables_in_' . DB_DATABASE]) && substr($result['Tables_in_' . DB_DATABASE], 0, strlen(DB_PREFIX)) == DB_PREFIX) { | | 21: | $table_data[] = $result['Tables_in_' . DB_DATABASE]; | | 22: | } | | 23: | } | | 24: | | | 25: | return $table_data; | | 26: | } | | 27: | | | 28: | /** | | 29: | * Get Records | | 30: | * | | 31: | * @param string $table | | 32: | * @param int $start | | 33: | * @param int $limit | | 34: | * | | 35: | * @return array<int, array<string, mixed>> | | 36: | */ | | 37: | public function getRecords(string $table, int $start = 0, int $limit = 100): array { | | 38: | if ($start < 0) { | | 39: | $start = 0; | | 40: | } | | 41: | | | 42: | if ($limit < 1) { | | 43: | $limit = 10; | | 44: | } | | 45: | | | 46: | $query = $this->db->query("SELECT * FROM " . $table . " LIMIT " . (int)$start . "," . (int)$limit); | | 47: | | | 48: | if ($query->num_rows) { | | 49: | return $query->rows; | | 50: | } else { | | 51: | return []; | | 52: | } | | 53: | } | | 54: | | | 55: | /** | | 56: | * Get Total Records | | 57: | * | | 58: | * @param string $table | | 59: | * | | 60: | * @return int | | 61: | */ | | 62: | public function getTotalRecords(string $table): int { | | 63: | $query = $this->db->query("SELECT COUNT(*) AS total FROM " . $table . ""); | | 64: | | | 65: | if ($query->num_rows) { | | 66: | return (int)$query->row['total']; | | 67: | } else { | | 68: | return 0; | | 69: | } | | 70: | } | | 71: | } | | 72: | |

OpenCart API API documentation generated by ApiGen dev-master