summaryrefslogtreecommitdiff
path: root/includes/model/Shifts_model.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-07-28 20:11:09 +0200
committermsquare <msquare@notrademark.de>2017-07-28 20:11:09 +0200
commitf82e5456d22af7e39a22a9a64e74072cf01e0a31 (patch)
treec024194bd11621e1956a659a0ec91ee7c747b40c /includes/model/Shifts_model.php
parent69a1ee2bfefb43a802dea8cf0f833cbe0a00369c (diff)
dried code by introducing selectOne for select queries with only one result line expected
Diffstat (limited to 'includes/model/Shifts_model.php')
-rw-r--r--includes/model/Shifts_model.php18
1 files changed, 5 insertions, 13 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 939a4f4e..88b28998 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -112,7 +112,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
*/
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
{
- $result = DB::select('
+ return DB::selectOne('
SELECT
`NeededAngelTypes`.*,
`Shifts`.`SID`,
@@ -150,12 +150,6 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
$angeltype['id']
]
);
-
- if (empty($result)) {
- return null;
- }
-
- return $result[0];
}
/**
@@ -453,13 +447,13 @@ function Shift_update($shift)
*/
function Shift_update_by_psid($shift)
{
- $shift_source = DB::select('SELECT `SID` FROM `Shifts` WHERE `PSID`=?', [$shift['PSID']]);
+ $shift_source = DB::selectOne('SELECT `SID` FROM `Shifts` WHERE `PSID`=?', [$shift['PSID']]);
if (empty($shift_source)) {
throw new Exception('Shift not found.');
}
- $shift['SID'] = $shift_source[0]['SID'];
+ $shift['SID'] = $shift_source['SID'];
return Shift_update($shift);
}
@@ -537,18 +531,16 @@ function Shifts_by_user($user, $include_freeload_comments = false)
*/
function Shift($shift_id)
{
- $shifts_source = DB::select('
+ $result = DB::selectOne('
SELECT `Shifts`.*, `ShiftTypes`.`name`
FROM `Shifts`
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
WHERE `SID`=?', [$shift_id]);
- if (empty($shifts_source)) {
+ if (empty($result)) {
return null;
}
- $result = $shifts_source[0];
-
$shiftsEntry_source = DB::select('
SELECT `id`, `TID` , `UID` , `freeloaded`
FROM `ShiftEntry`