diff --git a/helpers/track.php b/helpers/track.php index 66c8f3a..a6b3b78 100644 --- a/helpers/track.php +++ b/helpers/track.php @@ -155,14 +155,19 @@ public static function deleteAll($userId) { $ret = false; if (!empty($userId)) { - $query = "DELETE FROM `" . self::db()->table('tracks') . "` WHERE user_id = ?"; - $stmt = self::db()->prepare($query); - $stmt->bind_param('i', $userId); - $stmt->execute(); - if (!self::db()->error && !$stmt->errno) { - $ret = true; + // remove all positions + if (uPosition::deleteAll($userId) === true) { + // remove all tracks + $query = "DELETE FROM `" . self::db()->table('tracks') . "` WHERE user_id = ?"; + $stmt = self::db()->prepare($query); + $stmt->bind_param('i', $userId); + $stmt->execute(); + if (!self::db()->error && !$stmt->errno) { + $ret = true; + } + $stmt->close(); } - $stmt->close(); + } return $ret; } diff --git a/helpers/user.php b/helpers/user.php index 65fa0dd..474c736 100644 --- a/helpers/user.php +++ b/helpers/user.php @@ -100,11 +100,7 @@ public function delete() { $ret = false; if ($this->isValid) { - // remove positions - if (uPosition::deleteAll($this->id) === false) { - return false; - } - // remove tracks + // remove tracks and positions if (uTrack::deleteAll($this->id) === false) { return false; }