diff --git a/_sakura/components/Database.php b/_sakura/components/Database.php index a514921..809768e 100755 --- a/_sakura/components/Database.php +++ b/_sakura/components/Database.php @@ -78,4 +78,12 @@ class Database return self::$database->count($table, $data, $prefix); } + + // Get the ID of the last inserted item + public static function lastInsertID($name = null) + { + + return self::$database->lastInsertID($name); + + } } diff --git a/_sakura/components/Forum.php b/_sakura/components/Forum.php index c443817..e5a0742 100755 --- a/_sakura/components/Forum.php +++ b/_sakura/components/Forum.php @@ -387,7 +387,9 @@ class Forum ]); // Fetch the last insert - $getThread = Database::fetch('topics', false, null, ['topic_id', true]); + $getThread = Database::fetch('topics', false, [ + 'topic_id' => [Database::lastInsertID(), '='], + ]); } // Insert the post @@ -404,12 +406,14 @@ class Forum ]); // Fetch the last insert - $getPost = Database::fetch('posts', false, null, ['post_id', true]); + $getPost = Database::fetch('posts', false, [ + 'post_id' => [Database::lastInsertID(), '='], + ]); // Update the topic with the last details Database::update('topics', [ [ - 'topic_last_reply' => time(), + 'topic_last_reply' => $getPost['post_id'], ], [ 'topic_id' => [$getPost['topic_id'], '='], diff --git a/_sakura/components/database/mysql.php b/_sakura/components/database/mysql.php index e2ebe4b..542db69 100755 --- a/_sakura/components/database/mysql.php +++ b/_sakura/components/database/mysql.php @@ -388,4 +388,12 @@ class MySQL return $query->fetch(PDO::FETCH_BOTH); } + + // Get the ID of the last inserted item + public function lastInsertID($name = null) + { + + return $this->sql->lastInsertID($name);; + + } } diff --git a/_sakura/sakura.php b/_sakura/sakura.php index 557b4b3..bd6734d 100755 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20151018'); +define('SAKURA_VERSION', '20151019'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_STABLE', false); @@ -76,14 +76,10 @@ if (Configuration::getConfig('no_cron_service')) { // Update last execution time Database::update('config', [ [ - 'config_value' => time(), - ], [ - 'config_name' => ['no_cron_last', '='], - ], ]); diff --git a/_sakura/templates/yuuno/forum/forumEntry.tpl b/_sakura/templates/yuuno/forum/forumEntry.tpl index 8d77d0d..45414fd 100755 --- a/_sakura/templates/yuuno/forum/forumEntry.tpl +++ b/_sakura/templates/yuuno/forum/forumEntry.tpl @@ -29,7 +29,8 @@