summaryrefslogtreecommitdiff
path: root/includes/model/User_model.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-07-28 19:15:52 +0200
committermsquare <msquare@notrademark.de>2017-07-28 19:15:52 +0200
commita0af8d4624be9ca8579817d291036a6727aeb574 (patch)
tree869e7c39a3ec05aa6a4e478b51eb59bbf42746d1 /includes/model/User_model.php
parent5794c4cab8f6ef0529dfc51343b5ec78b134fb2a (diff)
further switching to db exceptions instead of return false
Diffstat (limited to 'includes/model/User_model.php')
-rw-r--r--includes/model/User_model.php40
1 files changed, 5 insertions, 35 deletions
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index adf81393..b08569d0 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -184,23 +184,17 @@ function User_sortable_columns()
* Get all users, ordered by Nick by default or by given param.
*
* @param string $order_by
- * @return array|false
+ * @return array
*/
function Users($order_by = 'Nick')
{
- $result = DB::select(sprintf('
+ return DB::select(sprintf('
SELECT *
FROM `User`
ORDER BY `%s` ASC
',
trim(DB::getPdo()->quote($order_by), '\'')
));
-
- if (DB::getStm()->errorCode() != '00000') {
- return false;
- }
-
- return $result;
}
/**
@@ -224,7 +218,7 @@ function User_is_freeloader($user)
*/
function Users_by_angeltype_inverted($angeltype)
{
- $result = DB::select('
+ return DB::select('
SELECT `User`.*
FROM `User`
LEFT JOIN `UserAngelTypes`
@@ -236,10 +230,6 @@ function Users_by_angeltype_inverted($angeltype)
$angeltype['id']
]
);
- if (DB::getStm()->errorCode() != '00000') {
- engelsystem_error('Unable to load users.');
- }
- return $result;
}
/**
@@ -250,7 +240,7 @@ function Users_by_angeltype_inverted($angeltype)
*/
function Users_by_angeltype($angeltype)
{
- $result = DB::select('
+ return DB::select('
SELECT
`User`.*,
`UserAngelTypes`.`id` AS `user_angeltype_id`,
@@ -267,10 +257,6 @@ function Users_by_angeltype($angeltype)
$angeltype['id']
]
);
- if (DB::getStm()->errorCode() != '00000') {
- engelsystem_error('Unable to load members.');
- }
- return $result;
}
/**
@@ -397,10 +383,6 @@ function User($user_id)
{
$user_source = DB::select('SELECT * FROM `User` WHERE `UID`=? LIMIT 1', [$user_id]);
- if (DB::getStm()->errorCode() != '00000') {
- engelsystem_error('Unable to load user.');
- }
-
if (empty($user_source)) {
return null;
}
@@ -413,16 +395,12 @@ function User($user_id)
*
* @param string $api_key
* User api key
- * @return array|null Matching user, null on error
+ * @return array|null Matching user, null if not found
*/
function User_by_api_key($api_key)
{
$user = DB::select('SELECT * FROM `User` WHERE `api_key`=? LIMIT 1', [$api_key]);
- if (DB::getStm()->errorCode() != '00000') {
- engelsystem_error('Unable to find user by api key.');
- }
-
if (empty($user)) {
return null;
}
@@ -440,10 +418,6 @@ function User_by_email($email)
{
$user = DB::select('SELECT * FROM `User` WHERE `email`=? LIMIT 1', [$email]);
- if (DB::getStm()->errorCode() != '00000') {
- engelsystem_error('Unable to load user.');
- }
-
if (empty($user)) {
return null;
}
@@ -461,10 +435,6 @@ function User_by_password_recovery_token($token)
{
$user = DB::select('SELECT * FROM `User` WHERE `password_recovery_token`=? LIMIT 1', [$token]);
- if (DB::getStm()->errorCode() != '00000') {
- engelsystem_error('Unable to load user.');
- }
-
if (empty($user)) {
return null;
}