$sql = "ALTER TABLE `" . PERCH_DB_PREFIX . "blog_posts` ADD INDEX `idx_status` (`postStatus`)`"; $db->execute($sql); $sql = "ALTER TABLE `" . PERCH_DB_PREFIX . "blog_posts` ADD INDEX `idx_section` (`sectionID`)`"; $db->execute($sql); $sql = "CREATE TABLE `" . PERCH_DB_PREFIX . "blog_sections` (\n\t `sectionID` int(11) NOT NULL AUTO_INCREMENT,\n\t `sectionTitle` varchar(255) NOT NULL DEFAULT '',\n\t `sectionSlug` varchar(255) NOT NULL DEFAULT '',\n\t `sectionPostCount` int(10) unsigned NOT NULL DEFAULT '0',\n\t `sectionDynamicFields` text,\n\t PRIMARY KEY (`sectionID`),\n\t KEY `idx_slug` (`sectionSlug`)\n\t ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC"; $db->execute($sql); $sql = "INSERT INTO `" . PERCH_DB_PREFIX . "blog_sections` (sectionID, sectionTitle, sectionSlug, sectionPostCount, sectionDynamicFields) VALUES ('1', 'Posts', 'posts', 0, '')"; $db->execute($sql); // 5.0 $sql = "CREATE TABLE IF NOT EXISTS `" . PERCH_DB_PREFIX . "blog_index` (\n\t\t `indexID` int(10) NOT NULL AUTO_INCREMENT,\n\t\t `itemKey` char(64) NOT NULL DEFAULT '-',\n\t\t `itemID` int(10) NOT NULL DEFAULT '0',\n\t\t `indexKey` char(64) NOT NULL DEFAULT '-',\n\t\t `indexValue` char(255) NOT NULL DEFAULT '',\n\t\t PRIMARY KEY (`indexID`),\n\t\t KEY `idx_fk` (`itemKey`,`itemID`),\n\t\t KEY `idx_key` (`indexKey`),\n\t\t KEY `idx_key_val` (`indexKey`,`indexValue`),\n\t\t KEY `idx_keys` (`itemKey`,`indexKey`)\n\t\t ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $db->execute($sql); $sql = "ALTER TABLE `" . PERCH_DB_PREFIX . "blog_categories` ADD `categoryCoreID` INT(10) NULL DEFAULT NULL AFTER `categoryDynamicFields`"; $db->execute($sql); $Core_CategorySets = new PerchCategories_Sets(); $Core_Categories = new PerchCategories_Categories(); $Set = $Core_CategorySets->get_by('setSlug', 'blog'); if (!$Set) { $Set = $Core_CategorySets->create(array('setTitle' => PerchLang::get('Blog'), 'setSlug' => 'blog', 'setTemplate' => '~/perch_blog/templates/blog/category_set.html', 'setCatTemplate' => '~/perch_blog/templates/blog/category.html', 'setDynamicFields' => '[]')); $cats = $db->get_rows('SELECT * FROM ' . PERCH_DB_PREFIX . 'blog_categories'); if (PerchUtil::count($cats)) { foreach ($cats as $cat) { $dynfields = '[]'; if ($cat['categoryDynamicFields']) { $dynfields = $cat['categoryDynamicFields']; } $NewCat = $Core_Categories->create(array('setID' => $Set->id(), 'catParentID' => 0, 'catTitle' => $cat['categoryTitle'], 'catSlug' => $cat['categorySlug'], 'catPath' => '/blog/' . $cat['categorySlug'] . '/', 'catDynamicFields' => $dynfields)); if (is_object($NewCat)) { $db->update(PERCH_DB_PREFIX . 'blog_categories', array('categoryCoreID' => $NewCat->id()), 'categoryID', $cat['categoryID']); } } }
<?php if (!defined('PERCH_DB_PREFIX')) { exit; } $sql = "\n CREATE TABLE `__PREFIX__root_locator_addresses` (\n `addressID` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `addressTitle` varchar(255) NOT NULL DEFAULT '',\n `addressBuilding` varchar(255) DEFAULT '',\n `addressStreet` varchar(255) DEFAULT '',\n `addressTown` varchar(255) DEFAULT '',\n `addressRegion` varchar(255) DEFAULT '',\n `addressPostcode` varchar(15) DEFAULT '',\n `addressCountry` varchar(3) DEFAULT '',\n `addressLatitude` decimal(9,6),\n `addressLongitude` decimal(9,6),\n `addressError` varchar(255),\n `addressDynamicFields` text,\n `addressUpdated` datetime NOT NULL,\n PRIMARY KEY (`addressID`),\n FULLTEXT KEY `root_locator_search_index` (`addressTitle`,`addressBuilding`,`addressStreet`,`addressPostcode`)\n ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n \n CREATE TABLE `__PREFIX__root_locator_index` (\n `indexID` int(10) NOT NULL AUTO_INCREMENT,\n `itemKey` char(64) NOT NULL DEFAULT '-',\n `itemID` int(10) NOT NULL DEFAULT '0',\n `indexKey` char(64) NOT NULL DEFAULT '-',\n `indexValue` char(255) NOT NULL DEFAULT '',\n PRIMARY KEY (`indexID`),\n KEY `idx_fk` (`itemKey`,`itemID`),\n KEY `idx_key` (`indexKey`),\n KEY `idx_key_val` (`indexKey`,`indexValue`),\n KEY `idx_keys` (`itemKey`,`indexKey`)\n ) ENGINE=MyISAM DEFAULT CHARSET=utf8;\n \n CREATE TABLE `__PREFIX__root_locator_tasks` (\n `taskID` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `taskKey` VARCHAR(255) NOT NULL,\n `addressID` int(11) unsigned NOT NULL,\n `taskAttempt` int(1) unsigned NOT NULL DEFAULT 1,\n `taskStart` datetime NOT NULL,\n PRIMARY KEY (`taskID`)\n ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;\n"; $sql = str_replace('__PREFIX__', PERCH_DB_PREFIX, $sql); // Install $statements = explode(';', $sql); foreach ($statements as $statement) { $statement = trim($statement); if ($statement != '') { $this->db->execute($statement); } } // Permissions $API = new PerchAPI(1.0, 'root_locator'); $UserPrivileges = $API->get('UserPrivileges'); $UserPrivileges->create_privilege('root_locator', 'Access the locator app'); $UserPrivileges->create_privilege('root_locator.import', 'Mass import location data'); // Categories $Core_CategorySets = new PerchCategories_Sets(); $Core_Categories = new PerchCategories_Categories(); $Set = $Core_CategorySets->get_by('setSlug', 'locator'); if (!$Set) { $Set = $Core_CategorySets->create(array('setTitle' => PerchLang::get('Locator'), 'setSlug' => 'locator', 'setTemplate' => '~/root_locator/templates/locator/category_set.html', 'setCatTemplate' => '~/root_locator/templates/locator/category.html', 'setDynamicFields' => '[]')); } // Installation check $sql = 'SHOW TABLES LIKE "' . $this->table . '"'; $result = $this->db->get_value($sql); return $result;