Update for category structure
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 23 Jan 2017 14:05:54 +0000 (09:05 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 23 Jan 2017 14:05:54 +0000 (09:05 -0500)
Adding name_slug

setup/databaseScripts/create_database_V0.1.1.sql
setup/databaseScripts/update_database_V0.0.2.php
setup/databaseScripts/update_database_V0.1.2.php [new file with mode: 0644]
setup/databaseScripts/update_database_V0.1.2.sql [new file with mode: 0644]

index 4592c21..a06c0b7 100644 (file)
@@ -62,6 +62,7 @@ CREATE TABLE {prefix}grouped_amenities (
 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),
index 37c440e..4d3c485 100644 (file)
@@ -11,15 +11,15 @@ if ($eventRecords && count($eventRecords) > 0) {
     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
+?>
diff --git a/setup/databaseScripts/update_database_V0.1.2.php b/setup/databaseScripts/update_database_V0.1.2.php
new file mode 100644 (file)
index 0000000..2dbbfe6
--- /dev/null
@@ -0,0 +1,25 @@
+<?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')
+        );
+    }
+}
+
+?>
diff --git a/setup/databaseScripts/update_database_V0.1.2.sql b/setup/databaseScripts/update_database_V0.1.2.sql
new file mode 100644 (file)
index 0000000..a726ff6
--- /dev/null
@@ -0,0 +1,11 @@
+-- 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;