Db::selectOne() should return null if result is empty
This commit is contained in:
parent
6ee738f82b
commit
175c335810
|
@ -182,7 +182,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
|
|||
/**
|
||||
* @param array $shift
|
||||
* @param array $angeltype
|
||||
* @return array
|
||||
* @return array|null
|
||||
*/
|
||||
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,7 @@ function user_myshifts()
|
|||
$shifts_user['UID'],
|
||||
]
|
||||
);
|
||||
if (count($shift) > 0) {
|
||||
if (!empty($shift)) {
|
||||
$freeloaded = $shift['freeloaded'];
|
||||
$freeload_comment = $shift['freeload_comment'];
|
||||
|
||||
|
|
|
@ -45,14 +45,19 @@ class Db
|
|||
*
|
||||
* @param string $query
|
||||
* @param array $bindings
|
||||
* @return array
|
||||
* @return array|null
|
||||
*/
|
||||
public static function selectOne($query, array $bindings = [])
|
||||
{
|
||||
$result = self::connection()->selectOne($query, $bindings);
|
||||
|
||||
// @TODO: remove typecast
|
||||
return (array)$result;
|
||||
$result = (array)$result;
|
||||
if (empty($result)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue