diff --git a/htdocs/core/class/unitsTools.class.php b/htdocs/core/class/unitsTools.class.php index 79ffdb82338..a5bc839da0c 100644 --- a/htdocs/core/class/unitsTools.class.php +++ b/htdocs/core/class/unitsTools.class.php @@ -63,9 +63,10 @@ class UnitsTools */ static public function scaleOfUnitPow($id) { + global $db; $base = 10; // TODO : add base col into unit dictionary table - $unit = self::dbGetRow('SELECT scale, unit_type from '.MAIN_DB_PREFIX.'c_units WHERE rowid = '.intval($id)); + $unit = $db->getRow('SELECT scale, unit_type from '.MAIN_DB_PREFIX.'c_units WHERE rowid = '.intval($id)); if($unit){ // TODO : if base exist in unit dictionary table remove this convertion exception and update convertion infos in database exemple time hour currently scale 3600 will become scale 2 base 60 if($unit->unit_type == 'time'){ @@ -77,43 +78,4 @@ class UnitsTools 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; - } } diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 96e76097877..c38db8f9c99 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -297,4 +297,42 @@ abstract class DoliDB implements Database { return $this->lastqueryerror; } + + + /** + * return first result value from query + * @param string $sql the sql query string + * @return bool| var + */ + public function getvalue($sql) + { + $sql .= ' LIMIT 1;'; + + $res = $this->query($sql); + if ($res) + { + $Tresult = $this->fetch_row($res); + return $Tresult[0]; + } + + return false; + } + + /** + * return first result from query as object + * @param string $sql the sql query string + * @return bool| var + */ + public function getRow($sql) + { + $sql .= ' LIMIT 1;'; + + $res = $this->query($sql); + if ($res) + { + return $this->fetch_object($res); + } + + return false; + } }