| 1 |
<?php |
| 2 |
/** |
| 3 |
* Table meta class |
| 4 |
* |
| 5 |
* @author GamiPress <[email protected]>, Ruben Garcia <[email protected]> |
| 6 |
* |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
defined( 'ABSPATH' ) || exit; |
| 11 |
|
| 12 |
if ( ! class_exists( 'CT_Table_Meta' ) ) : |
| 13 |
|
| 14 |
class CT_Table_Meta { |
| 15 |
|
| 16 |
/** |
| 17 |
* Table key. |
| 18 |
* |
| 19 |
* @since 1.0.0 |
| 20 |
* @access public |
| 21 |
* @var string $name |
| 22 |
*/ |
| 23 |
public $name; |
| 24 |
|
| 25 |
/** |
| 26 |
* Table Meta database. |
| 27 |
* |
| 28 |
* @since 1.0.0 |
| 29 |
* @access public |
| 30 |
* @var CT_DataBase $db |
| 31 |
*/ |
| 32 |
public $db; |
| 33 |
|
| 34 |
/** |
| 35 |
* Table Meta table object. |
| 36 |
* |
| 37 |
* @since 1.0.0 |
| 38 |
* @access public |
| 39 |
* @var CT_Table $table |
| 40 |
*/ |
| 41 |
public $table; |
| 42 |
|
| 43 |
/** |
| 44 |
* CT_Table_Meta constructor. |
| 45 |
* @param CT_Table $table |
| 46 |
*/ |
| 47 |
public function __construct( $table ) { |
| 48 |
|
| 49 |
$this->table = $table; |
| 50 |
$this->name = $this->table->name . '_meta'; |
| 51 |
|
| 52 |
$this->db = new CT_DataBase( $this->name, array( |
| 53 |
'version' => 1, |
| 54 |
'global' => $this->table->db->global, |
| 55 |
'schema' => array( |
| 56 |
'meta_id' => array( |
| 57 |
'type' => 'bigint', |
| 58 |
'length' => 20, |
| 59 |
'unsigned' => true, |
| 60 |
'nullable' => false, |
| 61 |
'auto_increment' => true, |
| 62 |
'primary_key' => true |
| 63 |
), |
| 64 |
$this->table->db->primary_key => array( |
| 65 |
'type' => 'bigint', |
| 66 |
'length' => 20, |
| 67 |
'unsigned' => true, |
| 68 |
'nullable' => false, |
| 69 |
'default' => 0, |
| 70 |
'key' => true |
| 71 |
), |
| 72 |
'meta_key' => array( |
| 73 |
'type' => 'varchar', |
| 74 |
'length' => 255, |
| 75 |
'nullable' => true, |
| 76 |
'default' => null, |
| 77 |
'key' => true |
| 78 |
), |
| 79 |
'meta_value' => array( |
| 80 |
'type' => 'longtext', |
| 81 |
'nullable' => true, |
| 82 |
'default' => null |
| 83 |
), |
| 84 |
) |
| 85 |
) ); |
| 86 |
|
| 87 |
} |
| 88 |
|
| 89 |
} |
| 90 |
|
| 91 |
endif; |