PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 153
Lasso Lite – Affiliate Link Manager & Product Displays v153
158 157 155 156 154 153 152 151 150 149 148 trunk 0.9.9 104 105 106 107 108 109 110 111 112 113 114 115 All 57 releases
simple-urls / models / class-revert.php

class-revert.php in Lasso Lite – Affiliate Link Manager & Product Displays 153, at models/class-revert.php

91 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 * Models
4 *
5 * @package Models
6 */
7
8 namespace LassoLite\Models;
9
10 /**
11 * Model
12 */
13 class Revert extends Model {
14 /**
15 * Table name
16 *
17 * @var string
18 */
19 protected $table = 'lasso_lite_revert';
20
21 /**
22 * Columns of the table
23 *
24 * @var array
25 */
26 protected $columns = array(
27 'id',
28 'lasso_id',
29 'post_data',
30 'old_uri',
31 'plugin',
32
33 'revert_dt',
34 );
35
36 /**
37 * Primary key of the table
38 *
39 * @var string
40 */
41 protected $primary_key = 'id';
42
43 /**
44 * Create table
45 */
46 public function create_table() {
47 $columns_sql = '
48 id bigint(10) NOT NULL AUTO_INCREMENT,
49 lasso_id bigint(20) NOT NULL,
50 post_data text NULL,
51 old_uri varchar(500) NOT NULL,
52 plugin varchar(200) NOT NULL,
53 revert_dt datetime NOT NULL,
54 PRIMARY KEY (id),
55 KEY ix_lasso_id (lasso_id)
56 ';
57 $sql = '
58 CREATE TABLE ' . $this->get_table_name() . ' (
59 ' . $columns_sql . '
60 ) ' . $this->get_charset_collate();
61
62 return $this->modify_table( $sql, $this->get_table_name() );
63 }
64
65 /**
66 * Update DB structure and data for v228
67 */
68 public function update_for_v228() {
69 // ? change datetime column to not null
70 $query = '
71 ALTER TABLE ' . $this->get_table_name() . '
72 CHANGE `revert_dt` `revert_dt` DATETIME NOT NULL
73 ';
74 self::query( $query );
75 }
76
77 /**
78 * Add lasso_id index for revert lookups (v152+).
79 */
80 public function update_for_v152() {
81 $index_name = 'ix_lasso_id';
82 $table = $this->get_table_name();
83 $exists = self::get_var(
84 "SHOW INDEX FROM {$table} WHERE Key_name = '{$index_name}'"
85 );
86 if ( ! $exists ) {
87 self::query( "ALTER TABLE {$table} ADD KEY {$index_name} (lasso_id)" );
88 }
89 }
90 }
91