diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-08-19 11:35:09 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-08-19 11:35:09 +0000 |
| commit | 84a4272b58e6bcc5be3366adc5771851c522eae3 (patch) | |
| tree | e088fd336667817dda9b8b89ddb3ea0ee6a327b8 /frontends/php/include/config.inc.php | |
| parent | c18881cf3bf1288bff75ecb10df386ec25a0cab9 (diff) | |
- [DEV-137] improvements in sqls (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5926 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/config.inc.php')
| -rw-r--r-- | frontends/php/include/config.inc.php | 44 |
1 files changed, 8 insertions, 36 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index f1c582c8..d9c8053f 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -1049,8 +1049,8 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! function update_valuemap($valuemapid, $name, $mappings){ if(!is_array($mappings)) return FALSE; - $result = DBexecute("update valuemaps set name=".zbx_dbstr($name). - " WHERE valuemapid=$valuemapid"); + $result = DBexecute('UPDATE valuemaps SET name='.zbx_dbstr($name). + ' WHERE valuemapid='.$valuemapid); if(!$result) return $result; @@ -1063,16 +1063,17 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! } function delete_valuemap($valuemapid){ - DBexecute("delete FROM mappings WHERE valuemapid=$valuemapid"); - DBexecute("delete FROM valuemaps WHERE valuemapid=$valuemapid"); + DBexecute('DELETE FROM mappings WHERE valuemapid='.$valuemapid); + DBexecute('DELETE FROM valuemaps WHERE valuemapid='.$valuemapid); return TRUE; } function replace_value_by_map($value, $valuemapid){ if($valuemapid < 1) return $value; - $result = DBselect("SELECT newvalue FROM mappings". - " WHERE valuemapid=".zbx_dbstr($valuemapid)." and value=".zbx_dbstr($value)); + $result = DBselect('SELECT newvalue FROM mappings '. + ' WHERE valuemapid='.$valuemapid. + ' AND value='.zbx_dbstr($value)); $row = DBfetch($result); if($row){ return $row["newvalue"]." "."($value)"; @@ -1152,36 +1153,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! } // Special processing for seconds if($units=="s"){ - $ret=""; - - $t=floor($value/(365*24*3600)); - if($t>0){ - $ret=$t."y"; - $value=$value-$t*(365*24*3600); - } - $t=floor($value/(30*24*3600)); - if($t>0){ - $ret=$ret.$t."m"; - $value=$value-$t*(30*24*3600); - } - $t=floor($value/(24*3600)); - if($t>0){ - $ret=$ret.$t."d"; - $value=$value-$t*(24*3600); - } - $t=floor($value/(3600)); - if($t>0){ - $ret=$ret.$t."h"; - $value=$value-$t*(3600); - } - $t=floor($value/(60)); - if($t>0){ - $ret=$ret.$t."m"; - $value=$value-$t*(60); - } - $ret=$ret.round($value, 2)."s"; - - return $ret; + return zbx_date2age(0,$value,true); } $u=""; |
