From 356b2582f3e6a43ecf2607acad4a7fe0b37f659a Mon Sep 17 00:00:00 2001 From: Bot Date: Tue, 3 Jan 2017 03:22:48 +0100 Subject: PPHDoc, formatting, fixes, cleanup --- includes/mysqli_provider.php | 54 ++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 17 deletions(-) (limited to 'includes/mysqli_provider.php') diff --git a/includes/mysqli_provider.php b/includes/mysqli_provider.php index 7280cd6d..2d991f4d 100644 --- a/includes/mysqli_provider.php +++ b/includes/mysqli_provider.php @@ -1,7 +1,11 @@ query($query); if ($result) { $data = []; @@ -159,7 +165,7 @@ function sql_select($query) * MySQL execute a query * * @param string $query - * @return mysqli_result boolean resource or false on error + * @return mysqli_result|false boolean resource or false on error */ function sql_query($query) { @@ -224,7 +230,21 @@ function sql_select_single_col($query) return array_map('array_shift', $result); } +/** + * @param string $query + * @return string|null + */ function sql_select_single_cell($query) { - return array_shift(array_shift(sql_select($query))); + $result = sql_select($query); + if ($result == false) { + return null; + } + + $result = array_shift($result); + if (!is_array($result)) { + return null; + } + + return array_shift($result); } -- cgit v1.2.3-54-g00ecf