PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.11
Booking for Appointments and Events Calendar – Amelia v1.2.11
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / InstallActions / DB / AbstractDatabaseTable.php
ameliabooking / src / Infrastructure / WP / InstallActions / DB Last commit date
Bookable 2 years ago Booking 1 year ago Cache 5 years ago Coupon 3 years ago CustomField 2 years ago Gallery 5 years ago Location 4 years ago Notification 1 year ago Payment 1 year ago Tax 2 years ago User 1 year ago AbstractDatabaseTable.php 5 years ago
AbstractDatabaseTable.php
82 lines
1 <?php
2 /**
3 * @copyright © TMS-Plugins. All rights reserved.
4 * @licence See LICENCE.md for license details.
5 */
6
7 namespace AmeliaBooking\Infrastructure\WP\InstallActions\DB;
8
9 use AmeliaBooking\Domain\Common\Exceptions\InvalidArgumentException;
10
11 /**
12 * Class AbstractDatabaseTable
13 *
14 * @package AmeliaBooking\Infrastructure\WP\InstallActions\DB
15 */
16 class AbstractDatabaseTable
17 {
18 const TABLE = '';
19
20 /**
21 * @return string
22 * @throws InvalidArgumentException
23 */
24 public static function getTableName()
25 {
26 if (!static::TABLE) {
27 throw new InvalidArgumentException('Table name is not provided');
28 }
29
30 global $wpdb;
31 return $wpdb->prefix . 'amelia_' . static::TABLE;
32 }
33
34 /**
35 * Create new table in the database
36 */
37 public static function init()
38 {
39 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
40 dbDelta(static::buildTable());
41
42 global $wpdb;
43
44 foreach (static::alterTable() as $command) {
45 $wpdb->query($command);
46 }
47 }
48
49 /**
50 * Delete table table from the database
51 *
52 * @throws InvalidArgumentException
53 */
54 public static function delete()
55 {
56 global $wpdb;
57
58 $table = self::getTableName();
59
60 $sql = "DROP TABLE IF EXISTS {$table};";
61 $wpdb->query($sql);
62 }
63
64 /**
65 * @return boolean
66 */
67 public static function isValidTablePrefix()
68 {
69 global $wpdb;
70
71 return strlen($wpdb->prefix) <= 16;
72 }
73
74 /**
75 * @return array
76 */
77 public static function alterTable()
78 {
79 return [];
80 }
81 }
82