summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/namespace/Item.php8
-rw-r--r--database.sql6
2 files changed, 7 insertions, 7 deletions
diff --git a/core/namespace/Item.php b/core/namespace/Item.php
index 3192d05..d21a4d6 100644
--- a/core/namespace/Item.php
+++ b/core/namespace/Item.php
@@ -126,12 +126,12 @@ abstract class Item implements ItemInterface {
# Return previous item ID
#===============================================================================
public function getPrevID(): int {
- $execute = 'SELECT id FROM %s WHERE DATE(time_insert) <= DATE(?) AND id < ? ORDER BY time_insert DESC, id DESC LIMIT 1';
+ $execute = 'SELECT id FROM %s WHERE time_insert < ? ORDER BY time_insert DESC LIMIT 1';
$attribute = "{$this->Reflection->getNamespaceName()}\\Attribute";
$Statement = $this->Database->prepare(sprintf($execute, $attribute::TABLE));
- if($Statement->execute([$this->Attribute->get('time_insert'), $this->Attribute->get('id')])) {
+ if($Statement->execute([$this->Attribute->get('time_insert')])) {
return $Statement->fetchColumn();
}
@@ -142,12 +142,12 @@ abstract class Item implements ItemInterface {
# Return next item ID
#===============================================================================
public function getNextID(): int {
- $execute = 'SELECT id FROM %s WHERE DATE(time_insert) >= DATE(?) AND id > ? ORDER BY time_insert ASC, id DESC LIMIT 1';
+ $execute = 'SELECT id FROM %s WHERE time_insert > ? ORDER BY time_insert ASC LIMIT 1';
$attribute = "{$this->Reflection->getNamespaceName()}\\Attribute";
$Statement = $this->Database->prepare(sprintf($execute, $attribute::TABLE));
- if($Statement->execute([$this->Attribute->get('time_insert'), $this->Attribute->get('id')])) {
+ if($Statement->execute([$this->Attribute->get('time_insert')])) {
return $Statement->fetchColumn();
}
diff --git a/database.sql b/database.sql
index d85089a..9669280 100644
--- a/database.sql
+++ b/database.sql
@@ -55,10 +55,10 @@ INSERT INTO `user` (`id`, `time_insert`, `time_update`, `slug`, `username`, `pas
-- =============================================================================
-- Add keys for tables
-- =============================================================================
-ALTER TABLE `page` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `page_user` (`user`);
-ALTER TABLE `post` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `post_user` (`user`);
+ALTER TABLE `page` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `page_user` (`user`);
+ALTER TABLE `post` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `slug` (`slug`), ADD KEY `post_user` (`user`);
ALTER TABLE `post` ADD FULLTEXT KEY `body` (`body`);
-ALTER TABLE `user` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `slug` (`slug`);
+ALTER TABLE `user` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `time_insert` (`time_insert`), ADD UNIQUE KEY `username` (`username`), ADD UNIQUE KEY `slug` (`slug`);
-- =============================================================================
-- Add AUTO_INCREMENT for tables