From 4de3fcf5f5a21a64b992ec6c59375a0ea850da07 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 7 May 2018 22:00:26 -0400 Subject: [PATCH] Simplify the tag table - Remove auto increment id - Replaced nurl by profile id - Added primary key on the two remaining columns --- dfrndir.sql | 11 ++++------- include/submit.php | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dfrndir.sql b/dfrndir.sql index 21112f56..1be9434a 100644 --- a/dfrndir.sql +++ b/dfrndir.sql @@ -230,13 +230,10 @@ CREATE TABLE IF NOT EXISTS `sync-timestamps` ( -- CREATE TABLE IF NOT EXISTS `tag` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `term` char(255) NOT NULL, - `nurl` char(255) NOT NULL, - PRIMARY KEY (`id`), - KEY `term` (`term`(250)), - KEY `nurl` (`nurl`(250)) -) ENGINE=MyISAM AUTO_INCREMENT=101679 DEFAULT CHARSET=utf8mb4; + `term` varchar(50) NOT NULL, + `profile_id` int(11) NOT NULL, + PRIMARY KEY (`term`,`profile_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -------------------------------------------------------- diff --git a/include/submit.php b/include/submit.php index a61e7fb5..4001be85 100644 --- a/include/submit.php +++ b/include/submit.php @@ -39,8 +39,8 @@ function run_submit($url) `updated` = '%s' WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($profile_id) ); - $r = q("DELETE FROM `tag` WHERE `nurl` = '%s'", - dbesc($r[0]['nurl']) + $r = q("DELETE FROM `tag` WHERE `profile_id` = %d", + intval($profile_id) ); } @@ -188,9 +188,9 @@ function run_submit($url) $t = substr($t, 0, 254); if (strlen($t)) { - $r = q("INSERT INTO `tag` (`term`, `nurl`) VALUES ('%s', '%s') ", + $r = q("INSERT INTO `tag` (`term`, `profile_id`) VALUES ('%s', %d) ", dbesc($t), - dbesc($nurl) + intval($profile_id) ); } }