diff options
author | msquare <msquare@notrademark.de> | 2016-11-10 13:55:16 +0100 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2016-11-10 13:55:16 +0100 |
commit | 468a10774cee39d4f649e4e85906f228c8ed79a1 (patch) | |
tree | afab115be92e540d3adf7fbc543f612a314e1dfa /includes/model/UserDriverLicenses_model.php | |
parent | f6da9148e7fa2097688613f3dd6e097d9e71293a (diff) |
reduce complexity of user driver license controller
Diffstat (limited to 'includes/model/UserDriverLicenses_model.php')
-rw-r--r-- | includes/model/UserDriverLicenses_model.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/includes/model/UserDriverLicenses_model.php b/includes/model/UserDriverLicenses_model.php index 19f87e63..32785c92 100644 --- a/includes/model/UserDriverLicenses_model.php +++ b/includes/model/UserDriverLicenses_model.php @@ -7,6 +7,7 @@ function UserDriverLicense($user_id) { $user_driver_license = sql_select("SELECT * FROM `UserDriverLicenses` WHERE `user_id`='" . sql_escape($user_id) . "'"); if ($user_driver_license === false) { + engelsystem_error('Unable to load user driver license.'); return false; } if (count($user_driver_license) > 0) { @@ -27,7 +28,7 @@ function UserDriverLicense($user_id) { * @param bool $has_license_forklift */ function UserDriverLicenses_create($user_id, $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift) { - return sql_query(" + $result = sql_query(" INSERT INTO `UserDriverLicenses` SET `user_id`=" . sql_escape($user_id) . ", `has_car`=" . sql_bool($has_car) . ", @@ -36,6 +37,10 @@ function UserDriverLicenses_create($user_id, $has_car, $has_license_car, $has_li `has_license_7_5t_truck`=" . sql_bool($has_license_7_5t_truck) . ", `has_license_12_5t_truck`=" . sql_bool($has_license_12_5t_truck) . ", `has_license_forklift`=" . sql_bool($has_license_forklift)); + if ($result === false) { + engelsystem_error('Unable to create user driver license'); + } + return $result; } /** @@ -50,7 +55,7 @@ function UserDriverLicenses_create($user_id, $has_car, $has_license_car, $has_li * @param bool $has_license_forklift */ function UserDriverLicenses_update($user_id, $has_car, $has_license_car, $has_license_3_5t_transporter, $has_license_7_5t_truck, $has_license_12_5t_truck, $has_license_forklift) { - return sql_query("UPDATE `UserDriverLicenses` SET + $result = sql_query("UPDATE `UserDriverLicenses` SET `has_car`=" . sql_bool($has_car) . ", `has_license_car`=" . sql_bool($has_license_car) . ", `has_license_3_5t_transporter`=" . sql_bool($has_license_3_5t_transporter) . ", @@ -58,6 +63,10 @@ function UserDriverLicenses_update($user_id, $has_car, $has_license_car, $has_li `has_license_12_5t_truck`=" . sql_bool($has_license_12_5t_truck) . ", `has_license_forklift`=" . sql_bool($has_license_forklift) . " WHERE `user_id`='" . sql_escape($user_id) . "'"); + if ($result === false) { + engelsystem_error("Unable to update user driver license information"); + } + return $result; } /** @@ -66,6 +75,10 @@ function UserDriverLicenses_update($user_id, $has_car, $has_license_car, $has_li * @param int $user_id */ function UserDriverLicenses_delete($user_id) { - return sql_query("DELETE FROM `UserDriverLicenses` WHERE `user_id`=" . sql_escape($user_id)); + $result = sql_query("DELETE FROM `UserDriverLicenses` WHERE `user_id`=" . sql_escape($user_id)); + if ($result === false) { + engelsystem_error("Unable to remove user driver license information"); + } + return $result; } ?>
\ No newline at end of file |