diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2017-08-29 23:06:46 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2017-08-29 23:16:41 +0200 |
commit | d0074cf0069322fe175fb385b91c974fc2771547 (patch) | |
tree | 713fcb1f426c8a693938e3c8bbfc685e57f79e69 /includes/model/ShiftEntry_model.php | |
parent | 50da458d8907cc7c05938565faa80b271bbf9b3d (diff) | |
parent | 581b81f1b25dc6b6f0a3b34810c293738fd40217 (diff) |
Merge remote-tracking branch 'engelsystem/feature-igel-rewrite'
# Conflicts:
# includes/controller/angeltypes_controller.php
# includes/pages/admin_groups.php
# includes/pages/user_settings.php
# includes/sys_page.php
# src/Exceptions/Handler.php
# src/Http/Request.php
Diffstat (limited to 'includes/model/ShiftEntry_model.php')
-rw-r--r-- | includes/model/ShiftEntry_model.php | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php index d7810feb..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; } @@ -102,7 +101,6 @@ function ShiftEntry_create($shift_entry) * Update a shift entry. * * @param array $shift_entry - * @return bool */ function ShiftEntry_update($shift_entry) { @@ -120,39 +118,29 @@ function ShiftEntry_update($shift_entry) $shift_entry['id'] ] ); - - return (DB::getStm()->errorCode() == '00000'); } /** * Get a shift entry. * * @param int $shift_entry_id - * @return array|false|null + * @return array|null */ function ShiftEntry($shift_entry_id) { - $shift_entry = DB::select('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]); - if (DB::getStm()->errorCode() != '00000') { - return false; - } - if (empty($shift_entry)) { - return null; - } - return $shift_entry[0]; + return DB::selectOne('SELECT * FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]); } /** * Delete a shift entry. * * @param int $shift_entry_id - * @return bool */ function ShiftEntry_delete($shift_entry_id) { $shift_entry = ShiftEntry($shift_entry_id); mail_shift_removed(User($shift_entry['UID']), Shift($shift_entry['SID'])); - return DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]); + DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shift_entry_id]); } /** @@ -213,7 +201,7 @@ function ShiftEntries_finished_by_user($user) */ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) { - $result = DB::select(' + return DB::select(' SELECT * FROM `ShiftEntry` WHERE `SID` = ? @@ -224,10 +212,6 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) $angeltype_id, ] ); - if (DB::getStm()->errorCode() != '00000') { - engelsystem_error('Unable to load shift entries.'); - } - return $result; } /** |