summaryrefslogtreecommitdiff
path: root/includes/model/ShiftEntry_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/ShiftEntry_model.php
parent69a1ee2bfefb43a802dea8cf0f833cbe0a00369c (diff)
dried code by introducing selectOne for select queries with only one result line expected
Diffstat (limited to 'includes/model/ShiftEntry_model.php')
-rw-r--r--includes/model/ShiftEntry_model.php13
1 files changed, 3 insertions, 10 deletions
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php
index 563a611f..3a7254ad 100644
--- a/includes/model/ShiftEntry_model.php
+++ b/includes/model/ShiftEntry_model.php
@@ -28,10 +28,9 @@ function ShiftEntry_new()
*/
function ShiftEntries_freeleaded_count()
{
- $result = DB::select('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
- $result = array_shift($result);
+ $result = DB::selectOne('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
- if (!is_array($result)) {
+ if (empty($result)) {
return 0;
}
@@ -129,13 +128,7 @@ function ShiftEntry_update($shift_entry)
*/
function ShiftEntry($shift_entry_id)
{
- $shift_entry = DB::select('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
-
- if (empty($shift_entry)) {
- return null;
- }
-
- return $shift_entry[0];
+ return DB::selectOne('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]);
}
/**