sqlplain.php
77 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | VAPLoader::import('libraries.backup.export.rule'); |
| 15 | |
| 16 | /** |
| 17 | * Plain SQL Backup export rule. |
| 18 | * |
| 19 | * @since 1.7.1 |
| 20 | * @since 1.7.4 The rule now directly extends `VAPBackupExportRuleSql` for a better reusability. |
| 21 | */ |
| 22 | class VAPBackupExportRuleSqlplain extends VAPBackupExportRuleSql |
| 23 | { |
| 24 | /** |
| 25 | * An array of SQL statements. |
| 26 | * |
| 27 | * @var array |
| 28 | */ |
| 29 | protected $queries = []; |
| 30 | |
| 31 | /** |
| 32 | * Returns the rule identifier. |
| 33 | * |
| 34 | * @return string |
| 35 | */ |
| 36 | public function getRule() |
| 37 | { |
| 38 | // treat as SQL role |
| 39 | return 'sql'; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Returns the rules instructions. |
| 44 | * |
| 45 | * @return mixed |
| 46 | */ |
| 47 | public function getData() |
| 48 | { |
| 49 | return $this->queries; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Configures the rule to work according to the specified data. |
| 54 | * |
| 55 | * @param mixed $data Either a query string or an array. |
| 56 | * |
| 57 | * @return void |
| 58 | */ |
| 59 | protected function setup($data) |
| 60 | { |
| 61 | // reset all the registered query |
| 62 | $this->queries = []; |
| 63 | |
| 64 | foreach ((array) $data as $query) |
| 65 | { |
| 66 | /** |
| 67 | * Register query through the apposite helper provided by the parent class. |
| 68 | * This way we can prevent the issue that occurs on WordPress while exporting SQL queries |
| 69 | * without executing them, namely that a "%" is always escaped with a random hash. |
| 70 | * |
| 71 | * @since 1.7.4 |
| 72 | */ |
| 73 | $this->registerQuery($query); |
| 74 | } |
| 75 | } |
| 76 | } |
| 77 |