Delete positions with tracks in deleteAll

This commit is contained in:
Bartek Fabiszewski 2017-08-17 17:18:41 +02:00
parent 65a5c95f67
commit 4ddbbb9807
2 changed files with 13 additions and 12 deletions

View File

@ -155,14 +155,19 @@
public static function deleteAll($userId) { public static function deleteAll($userId) {
$ret = false; $ret = false;
if (!empty($userId)) { if (!empty($userId)) {
$query = "DELETE FROM `" . self::db()->table('tracks') . "` WHERE user_id = ?"; // remove all positions
$stmt = self::db()->prepare($query); if (uPosition::deleteAll($userId) === true) {
$stmt->bind_param('i', $userId); // remove all tracks
$stmt->execute(); $query = "DELETE FROM `" . self::db()->table('tracks') . "` WHERE user_id = ?";
if (!self::db()->error && !$stmt->errno) { $stmt = self::db()->prepare($query);
$ret = true; $stmt->bind_param('i', $userId);
$stmt->execute();
if (!self::db()->error && !$stmt->errno) {
$ret = true;
}
$stmt->close();
} }
$stmt->close();
} }
return $ret; return $ret;
} }

View File

@ -100,11 +100,7 @@
public function delete() { public function delete() {
$ret = false; $ret = false;
if ($this->isValid) { if ($this->isValid) {
// remove positions // remove tracks and positions
if (uPosition::deleteAll($this->id) === false) {
return false;
}
// remove tracks
if (uTrack::deleteAll($this->id) === false) { if (uTrack::deleteAll($this->id) === false) {
return false; return false;
} }