Upgrades
5 years ago
AudioPresets.php
2 years ago
EmailCollection.php
5 years ago
Migrations.php
3 years ago
Presets.php
2 years ago
Table.php
4 years ago
Videos.php
4 years ago
Visits.php
4 years ago
Webhooks.php
3 years ago
Videos.php
66 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PrestoPlayer\Database; |
| 4 | |
| 5 | use PrestoPlayer\Database\Table; |
| 6 | |
| 7 | class Videos |
| 8 | { |
| 9 | protected $table; |
| 10 | protected $version = 4; |
| 11 | protected $name = 'presto_player_videos'; |
| 12 | |
| 13 | public function __construct(Table $table) |
| 14 | { |
| 15 | $this->table = $table; |
| 16 | } |
| 17 | |
| 18 | public function getName() |
| 19 | { |
| 20 | global $wpdb; |
| 21 | return $wpdb->prefix . $this->name; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Add videos table |
| 26 | * This is used for global video analytics |
| 27 | * |
| 28 | * @return void |
| 29 | */ |
| 30 | public function install() |
| 31 | { |
| 32 | return $this->table->create($this->name, " |
| 33 | id bigint(20) unsigned NOT NULL auto_increment, |
| 34 | title varchar(255) NOT NULL, |
| 35 | type varchar(155) NOT NULL, |
| 36 | external_id varchar(155) NULL, |
| 37 | attachment_id bigint(20) unsigned NULL, |
| 38 | post_id bigint(20) NULL, |
| 39 | src varchar(255) NULL, |
| 40 | created_by bigint(20) unsigned NULL, |
| 41 | created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), |
| 42 | updated_at TIMESTAMP NOT NULL, |
| 43 | deleted_at TIMESTAMP NULL, |
| 44 | PRIMARY KEY (id), |
| 45 | KEY external_id (external_id), |
| 46 | KEY attachment_id (attachment_id), |
| 47 | KEY created_at (created_at), |
| 48 | KEY updated_at (updated_at) |
| 49 | ", $this->version); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Uninstall tables |
| 54 | * |
| 55 | * @return void |
| 56 | */ |
| 57 | public function uninstall() |
| 58 | { |
| 59 | $this->table->drop($this->getName()); |
| 60 | } |
| 61 | |
| 62 | public function exists(){ |
| 63 | return $this->table->exists($this->name); |
| 64 | } |
| 65 | } |
| 66 |