Browse Source

Return the correct insert_id when adding a new album

Tobias Reich 8 years ago
parent
commit
9117402035
1 changed files with 5 additions and 4 deletions
  1. 5 4
      php/Modules/Album.php

+ 5 - 4
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;
 
 	}