From e915552ae18882a1c39d9a3252ba77e9d9c688f3 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sat, 18 Apr 2020 11:39:33 +0200 Subject: [PATCH] New class tool for converting units --- htdocs/core/class/unitsTools.class.php | 119 +++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 htdocs/core/class/unitsTools.class.php diff --git a/htdocs/core/class/unitsTools.class.php b/htdocs/core/class/unitsTools.class.php new file mode 100644 index 00000000000..79ffdb82338 --- /dev/null +++ b/htdocs/core/class/unitsTools.class.php @@ -0,0 +1,119 @@ +unit_type == 'time'){ + return doubleval($unit->scale); + } + + return pow($base, doubleval($unit->scale)); + } + + return 0; + } + + /** + * return first result from query + * @param string $sql the sql query string + * @return bool| var + */ + static public function dbGetvalue($sql) + { + global $db; + $sql .= ' LIMIT 1;'; + + $res = $db->query($sql); + if ($res) + { + $Tresult = $db->fetch_row($res); + return $Tresult[0]; + } + + return false; + } + + /** + * return first result from query + * @param string $sql the sql query string + * @return bool| var + */ + static public function dbGetRow($sql) + { + global $db; + $sql .= ' LIMIT 1;'; + + $res = $db->query($sql); + if ($res) + { + return $db->fetch_object($res); + } + + return false; + } +}