PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / trunk
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution vtrunk
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Timer / Tables / Timer_Table.php

Timer_Table.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution trunk, at src/Performance/Timer/Tables/Timer_Table.php

76 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The timer table to store timers.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Timer\Tables;
11
12 use SolidWP\Performance\StellarWP\DB\Database\Exceptions\DatabaseQueryException;
13 use SolidWP\Performance\StellarWP\Schema\Tables\Contracts\Table;
14
15 /**
16 * The timer table to store timers.
17 *
18 * @package SolidWP\Performance
19 */
20 final class Timer_Table extends Table {
21
22 const SCHEMA_VERSION = '1.0.3';
23
24 /**
25 * @var string The base table name.
26 */
27 protected static $base_table_name = 'swp_timers';
28
29 /**
30 * @var string The organizational group this table belongs to.
31 */
32 protected static $group = 'swpsp';
33
34 /**
35 * @var string|null The slug used to identify the custom table.
36 */
37 protected static $schema_slug = 'timers';
38
39 /**
40 * @var string The field that uniquely identifies a row in the table.
41 */
42 protected static $uid_column = 'timer_name';
43
44 /**
45 * Overload the update method to first drop the database as this is a temporary table.
46 *
47 * @throws DatabaseQueryException If any of the queries fail.
48 *
49 * @return string[]
50 */
51 public function update() {
52 if ( $this->exists() ) {
53 $this->drop();
54 }
55
56 return parent::update();
57 }
58
59 /**
60 * @return string
61 */
62 protected function get_definition(): string {
63 global $wpdb;
64 $table_name = self::table_name();
65 $charset_collate = $wpdb->get_charset_collate();
66
67 return "
68 CREATE TABLE `$table_name` (
69 `timer_name` varchar(191) NOT NULL,
70 `start_time` double NOT NULL,
71 PRIMARY KEY (`timer_name`)
72 ) {$charset_collate};
73 ";
74 }
75 }
76