CREATE TABLE {prefix}categories (
id INT NOT NULL AUTO_INCREMENT,
name TINYTEXT NULL, -- Name of event category
+ name_slug TINYTEXT NULL, -- Slug for this event category
descr TINYTEXT NULL, -- Description of this category
parent INT NULL, -- Parent category, null or 0 if this is a top level category
PRIMARY KEY (id),
foreach ($eventRecords as $i) {
$slug = sanitize_title($i['name']);
$this->wpdb->update(
- GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'events',
- array(
- 'name_slug' => $slug
- ),
- array( 'id' => $i['id'] ),
- array( '%s' ),
- array( '%d')
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'events',
+ array(
+ 'name_slug' => $slug
+ ),
+ array( 'id' => $i['id'] ),
+ array( '%s' ),
+ array( '%d')
);
}
}
-?>
\ No newline at end of file
+?>
--- /dev/null
+<?php
+/*
+ * Gaslight Media Members Database - Events Add-On
+ *
+ * Database Update Script for version 0.0.2
+ */
+
+// Update event records with name slug for URLs
+$eventRecords = $this->wpdb->get_results('SELECT id, name FROM '.GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'categories;', ARRAY_A);
+if ($eventRecords && count($eventRecords) > 0) {
+ foreach ($eventRecords as $i) {
+ $slug = sanitize_title($i['name']);
+ $this->wpdb->update(
+ GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'categories',
+ array(
+ 'name_slug' => $slug
+ ),
+ array( 'id' => $i['id'] ),
+ array( '%s' ),
+ array( '%d')
+ );
+ }
+}
+
+?>
--- /dev/null
+-- Gaslight Media Members Database - Events Add-On
+-- File Created: 2017-01-23
+-- Database Version: 0.0.24
+-- Database Update From Previous Version Script
+--
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashes
+
+
+-- Add slug to event table
+ALTER TABLE {prefix}categories ADD COLUMN name_slug TINYTEXT;