From 9117402035de99c2f0e4d4aaf7cb3670e7152e38 Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sun, 6 Mar 2016 21:01:51 +0100 Subject: [PATCH] Return the correct insert_id when adding a new album --- php/Modules/Album.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/php/Modules/Album.php b/php/Modules/Album.php index e4915a1..d95e18b 100644 --- a/php/Modules/Album.php +++ b/php/Modules/Album.php @@ -33,15 +33,16 @@ final class Album { $visible = 1; // Database - $sysstamp = time(); - $query = Database::prepare(Database::get(), "INSERT INTO ? (title, sysstamp, public, visible) VALUES ('?', '?', '?', '?')", array(LYCHEE_TABLE_ALBUMS, $title, $sysstamp, $public, $visible)); - $result = Database::execute(Database::get(), $query, __METHOD__, __LINE__); + $sysstamp = time(); + $query = Database::prepare(Database::get(), "INSERT INTO ? (title, sysstamp, public, visible) VALUES ('?', '?', '?', '?')", array(LYCHEE_TABLE_ALBUMS, $title, $sysstamp, $public, $visible)); + $result = Database::execute(Database::get(), $query, __METHOD__, __LINE__); + $insertID = Database::get()->insert_id; // Call plugins Plugins::get()->activate(__METHOD__, 1, func_get_args()); if ($result===false) return false; - return Database::get()->insert_id; + return $insertID; }