| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yatra\Database\Tables; |
| 4 |
|
| 5 |
/** |
| 6 |
* Base Table Class |
| 7 |
* |
| 8 |
* Parent class for all database table classes. |
| 9 |
* Handles WordPress prefix and provides common functionality. |
| 10 |
*/ |
| 11 |
abstract class BaseTable |
| 12 |
{ |
| 13 |
/** |
| 14 |
* Table name without prefix (to be defined in child classes) |
| 15 |
*/ |
| 16 |
protected static string $table = ''; |
| 17 |
|
| 18 |
/** |
| 19 |
* Get the full table name with WordPress prefix |
| 20 |
*/ |
| 21 |
public static function getTableName(): string |
| 22 |
{ |
| 23 |
global $wpdb; |
| 24 |
return $wpdb->prefix . static::$table; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Get the charset collate for table creation |
| 29 |
*/ |
| 30 |
public static function getCharsetCollate(): string |
| 31 |
{ |
| 32 |
global $wpdb; |
| 33 |
return $wpdb->get_charset_collate(); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Get the complete table schema as raw SQL CREATE TABLE statement |
| 38 |
*/ |
| 39 |
abstract public static function getSchema(): string; |
| 40 |
} |
| 41 |
|