From d7aea575ff77cd37c326511e7ac5fe49067c63ad Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 14 Oct 2018 18:24:42 +0200 Subject: Replaced more sql queries and old data --- includes/model/Message_model.php | 8 ++++---- includes/model/ShiftEntry_model.php | 8 ++------ includes/model/Shifts_model.php | 30 ++---------------------------- 3 files changed, 8 insertions(+), 38 deletions(-) (limited to 'includes/model') diff --git a/includes/model/Message_model.php b/includes/model/Message_model.php index 89beeb07..26f7e599 100644 --- a/includes/model/Message_model.php +++ b/includes/model/Message_model.php @@ -43,10 +43,10 @@ function Message_send($receiver_user_id, $text) if ( ($text != '' && is_numeric($receiver_user_id)) && count(DB::select(' - SELECT `UID` - FROM `User` - WHERE `UID` = ? - AND NOT `UID` = ? + SELECT `id` + FROM `users` + WHERE `id` = ? + AND NOT `id` = ? LIMIT 1 ', [$receiver_user_id, $user->id])) > 0 ) { diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php index 593e40b2..248e7d1e 100644 --- a/includes/model/ShiftEntry_model.php +++ b/includes/model/ShiftEntry_model.php @@ -48,11 +48,7 @@ function ShiftEntries_by_shift($shift_id) { return DB::select(' SELECT - `User`.`Nick`, - `User`.`email`, - `User`.`email_shiftinfo`, - `User`.`Sprache`, - `User`.`Gekommen`, + `users`.*, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, @@ -60,7 +56,7 @@ function ShiftEntries_by_shift($shift_id) `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded` FROM `ShiftEntry` - JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID` + JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` WHERE `ShiftEntry`.`SID` = ?', [$shift_id] diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 9e803efd..d7799a1e 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -235,11 +235,7 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { $sql = ' SELECT - `User`.`Nick`, - `User`.`email`, - `User`.`email_shiftinfo`, - `User`.`Sprache`, - `User`.`Gekommen`, + users.* `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, @@ -247,7 +243,7 @@ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) `ShiftEntry`.`freeloaded` FROM `Shifts` JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID` - JOIN `User` ON `ShiftEntry`.`UID`=`User`.`UID` + JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id` WHERE `Shifts`.`RID` IN (' . implode(',', $shiftsFilter->getRooms()) . ') AND `start` BETWEEN ? AND ? ORDER BY `Shifts`.`start`'; @@ -685,25 +681,3 @@ function Shift($shift_id) return $result; } - -/** - * Returns all shifts with needed angeltypes and count of subscribed jobs. - * - * @return array - */ -function Shifts() -{ - $shifts_source = DB::select(' - SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name` - FROM `Shifts` - JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) - JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID` - '); - - foreach ($shifts_source as &$shift) { - $needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']); - $shift['angeltypes'] = $needed_angeltypes; - } - - return $shifts_source; -} -- cgit v1.2.3-70-g09d2