Пример #1
0
 public function create()
 {
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $sql_1 = "CREATE TABLE IF NOT EXISTS " . $this->table_name . " (\n\t\t\t  id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  title varchar(225) NOT NULL,\n\t\t\t  description text DEFAULT NULL,\n\t\t\t  src varchar(225) NOT NULL,\n\t\t\t  href varchar(225) DEFAULT NULL,\n\t\t\t  date_create datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\t\t\t  status tinyint(1) NOT NULL DEFAULT '1',\n\t\t\t  slider_id int(11) NOT NULL,\n\t\t\t  PRIMARY KEY (id),\n\t\t\t  CONSTRAINT `foreign_slider` FOREIGN KEY (`slider_id`) REFERENCES " . $this->ref_table . "(`id`) \n \t\t\t)" . $this->chaset_collate . ";";
     dbdelta($sql_1);
 }
Пример #2
0
 public function create()
 {
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     $sql_2 = "CREATE TABLE IF NOT EXISTS " . $this->table_name . " (\n\t\t\t\t  id int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  name varchar(225) NOT NULL,\n\t\t\t\t  status tinyint(1) NOT NULL DEFAULT '1',\n\t\t\t\t  PRIMARY KEY (id)\n\t\t\t\t)" . $this->chaset_collate . ";";
     dbdelta($sql_2);
 }
Пример #3
0
 private function alterMMTables()
 {
     global $wpdb;
     $filename = "install_sql";
     require_once MM_PLUGIN_ABSPATH . "/data/{$filename}.php";
     if (isset($sql) && count($sql) > 0) {
         dbdelta($sql);
     }
     // Since DBDelta doesn't handle dropping column, here's where we can do it manually & safely. We first
     // check to see if the column even exists. This could happen if a client has deactivated the
     // plugin for some reason and then decides to reactivate.
     $droppedColumns = array();
     $droppedColumns[MM_TABLE_USER_DATA][] = "password";
     foreach ($droppedColumns as $table => $columns) {
         foreach ($columns as $column) {
             if ($this->hasColumn($table, $column)) {
                 $wpdb->query("ALTER TABLE {$table} DROP COLUMN {$column}");
             }
         }
     }
     return true;
 }