当前位置: 首页>>代码示例>>PHP>>正文


PHP zbx_db_distinct函数代码示例

本文整理汇总了PHP中zbx_db_distinct函数的典型用法代码示例。如果您正苦于以下问题:PHP zbx_db_distinct函数的具体用法?PHP zbx_db_distinct怎么用?PHP zbx_db_distinct使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zbx_db_distinct函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get


//.........这里部分代码省略.........
            $sortorder = $options['sortorder'] == ZBX_SORT_DOWN ? ZBX_SORT_DOWN : ZBX_SORT_UP;
            $sql_parts['order'][] = 's.' . $options['sortfield'] . ' ' . $sortorder;
            if (!str_in_array('s.' . $options['sortfield'], $sql_parts['select']) && !str_in_array('s.*', $sql_parts['select'])) {
                $sql_parts['select'][] = 's.' . $options['sortfield'];
            }
        }
        // limit
        if (zbx_ctype_digit($options['limit']) && $options['limit']) {
            $sql_parts['limit'] = $options['limit'];
        }
        //-------
        $sysmapids = array();
        $sql_parts['select'] = array_unique($sql_parts['select']);
        $sql_parts['from'] = array_unique($sql_parts['from']);
        $sql_parts['where'] = array_unique($sql_parts['where']);
        $sql_parts['order'] = array_unique($sql_parts['order']);
        $sql_select = '';
        $sql_from = '';
        $sql_where = '';
        $sql_order = '';
        if (!empty($sql_parts['select'])) {
            $sql_select .= implode(',', $sql_parts['select']);
        }
        if (!empty($sql_parts['from'])) {
            $sql_from .= implode(',', $sql_parts['from']);
        }
        if (!empty($sql_parts['where'])) {
            $sql_where .= ' AND ' . implode(' AND ', $sql_parts['where']);
        }
        if (!empty($sql_parts['order'])) {
            $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
        }
        $sql_limit = $sql_parts['limit'];
        $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . '
				FROM ' . $sql_from . '
				WHERE ' . DBin_node('s.sysmapid', $nodeids) . $sql_where . $sql_order;
        $res = DBselect($sql, $sql_limit);
        while ($sysmap = DBfetch($res)) {
            if ($options['countOutput']) {
                $result = $sysmap['rowscount'];
            } else {
                $sysmapids[$sysmap['sysmapid']] = $sysmap['sysmapid'];
                if ($options['output'] == API_OUTPUT_SHORTEN) {
                    $result[$sysmap['sysmapid']] = array('sysmapid' => $sysmap['sysmapid']);
                } else {
                    if (!isset($result[$sysmap['sysmapid']])) {
                        $result[$sysmap['sysmapid']] = array();
                    }
                    if (!is_null($options['select_selements']) && !isset($result[$sysmap['sysmapid']]['selements'])) {
                        $result[$sysmap['sysmapid']]['selements'] = array();
                    }
                    if (!is_null($options['select_links']) && !isset($result[$sysmap['sysmapid']]['links'])) {
                        $result[$sysmap['sysmapid']]['links'] = array();
                    }
                    if (isset($sysmap['highlight'])) {
                        $sysmap['expandproblem'] = $sysmap['highlight'] & ZBX_MAP_EXPANDPROBLEM ? 0 : 1;
                        $sysmap['markelements'] = $sysmap['highlight'] & ZBX_MAP_MARKELEMENTS ? 1 : 0;
                        if (($sysmap['highlight'] & ZBX_MAP_EXTACK_SEPARATED) == ZBX_MAP_EXTACK_SEPARATED) {
                            $sysmap['show_unack'] = EXTACK_OPTION_BOTH;
                        } else {
                            if ($sysmap['highlight'] & ZBX_MAP_EXTACK_UNACK) {
                                $sysmap['show_unack'] = EXTACK_OPTION_UNACK;
                            } else {
                                $sysmap['show_unack'] = EXTACK_OPTION_ALL;
                            }
                        }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.cmap.php

示例2: get


//.........这里部分代码省略.........
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'g');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $graphids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlGroup = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= ' AND ' . implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['group'])) {
         $sqlWhere .= ' GROUP BY ' . implode(',', $sqlParts['group']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     $sqlLimit = $sqlParts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . DBin_node('g.graphid', $nodeids) . $sqlWhere . $sqlGroup . $sqlOrder;
     $dbRes = DBselect($sql, $sqlLimit);
     while ($graph = DBfetch($dbRes)) {
         if (!is_null($options['countOutput'])) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $graph;
             } else {
                 $result = $graph['rowscount'];
             }
         } else {
             $graphids[$graph['graphid']] = $graph['graphid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$graph['graphid']] = array('graphid' => $graph['graphid']);
             } else {
                 if (!isset($result[$graph['graphid']])) {
                     $result[$graph['graphid']] = array();
                 }
                 if (!is_null($options['selectHosts']) && !isset($result[$graph['graphid']]['hosts'])) {
                     $result[$graph['graphid']]['hosts'] = array();
                 }
                 if (!is_null($options['selectGraphItems']) && !isset($result[$graph['graphid']]['gitems'])) {
                     $result[$graph['graphid']]['gitems'] = array();
                 }
                 if (!is_null($options['selectTemplates']) && !isset($result[$graph['graphid']]['templates'])) {
                     $result[$graph['graphid']]['templates'] = array();
                 }
                 if (!is_null($options['selectItems']) && !isset($result[$graph['graphid']]['items'])) {
                     $result[$graph['graphid']]['items'] = array();
                 }
                 if (!is_null($options['selectDiscoveryRule']) && !isset($result[$graph['graphid']]['discoveryRule'])) {
                     $result[$graph['graphid']]['discoveryRule'] = array();
                 }
                 // hostids
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CGraphPrototype.php

示例3: get


//.........这里部分代码省略.........
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sql_parts['limit'] = $options['limit'];
     }
     //-------
     $hostids = array();
     $sql_parts['select'] = array_unique($sql_parts['select']);
     $sql_parts['from'] = array_unique($sql_parts['from']);
     $sql_parts['where'] = array_unique($sql_parts['where']);
     $sql_parts['group'] = array_unique($sql_parts['group']);
     $sql_parts['order'] = array_unique($sql_parts['order']);
     $sql_select = '';
     $sql_from = '';
     $sql_where = '';
     $sql_group = '';
     $sql_order = '';
     if (!empty($sql_parts['select'])) {
         $sql_select .= implode(',', $sql_parts['select']);
     }
     if (!empty($sql_parts['from'])) {
         $sql_from .= implode(',', $sql_parts['from']);
     }
     if (!empty($sql_parts['where'])) {
         $sql_where .= implode(' AND ', $sql_parts['where']);
     }
     if (!empty($sql_parts['group'])) {
         $sql_where .= ' GROUP BY ' . implode(',', $sql_parts['group']);
     }
     if (!empty($sql_parts['order'])) {
         $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
     }
     $sql_limit = $sql_parts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . ' FROM ' . $sql_from . ' WHERE ' . $sql_where . $sql_group . $sql_order;
     //SDI($sql);
     $res = DBselect($sql, $sql_limit);
     while ($host = DBfetch($res)) {
         if (!is_null($options['countOutput'])) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $host;
             } else {
                 $result = $host['rowscount'];
             }
         } else {
             $hostids[$host['hostid']] = $host['hostid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$host['hostid']] = array('hostid' => $host['hostid']);
             } else {
                 if (!isset($result[$host['hostid']])) {
                     $result[$host['hostid']] = array();
                 }
                 if (!is_null($options['select_groups']) && !isset($result[$host['hostid']]['groups'])) {
                     $result[$host['hostid']]['groups'] = array();
                 }
                 if (!is_null($options['selectParentTemplates']) && !isset($result[$host['hostid']]['parentTemplates'])) {
                     $result[$host['hostid']]['parentTemplates'] = array();
                 }
                 if (!is_null($options['select_items']) && !isset($result[$host['hostid']]['items'])) {
                     $result[$host['hostid']]['items'] = array();
                 }
                 if (!is_null($options['select_profile']) && !isset($result[$host['hostid']]['profile'])) {
                     $result[$host['hostid']]['profile'] = array();
                     $result[$host['hostid']]['profile_ext'] = array();
                 }
                 if (!is_null($options['select_triggers']) && !isset($result[$host['hostid']]['triggers'])) {
                     $result[$host['hostid']]['triggers'] = array();
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.chost.php

示例4: get


//.........这里部分代码省略.........
             $sql_parts['select'][] = 'a.' . $options['sortfield'];
         }
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sql_parts['limit'] = $options['limit'];
     }
     //---------------
     $alertids = array();
     $userids = array();
     $hostids = array();
     $mediatypeids = array();
     $sql_parts['select'] = array_unique($sql_parts['select']);
     $sql_parts['from'] = array_unique($sql_parts['from']);
     $sql_parts['where'] = array_unique($sql_parts['where']);
     $sql_parts['order'] = array_unique($sql_parts['order']);
     $sql_select = '';
     $sql_from = '';
     $sql_where = '';
     $sql_order = '';
     if (!empty($sql_parts['select'])) {
         $sql_select .= implode(',', $sql_parts['select']);
     }
     if (!empty($sql_parts['from'])) {
         $sql_from .= implode(',', $sql_parts['from']);
     }
     if (!empty($sql_parts['where'])) {
         $sql_where .= ' AND ' . implode(' AND ', $sql_parts['where']);
     }
     if (!empty($sql_parts['order'])) {
         $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
     }
     $sql_limit = $sql_parts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . ' FROM ' . $sql_from . ' WHERE ' . DBin_node('a.alertid', $nodeids) . $sql_where . $sql_order;
     $db_res = DBselect($sql, $sql_limit);
     while ($alert = DBfetch($db_res)) {
         if ($options['countOutput']) {
             $result = $alert['rowscount'];
         } else {
             $alertids[$alert['alertid']] = $alert['alertid'];
             if (isset($alert['userid'])) {
                 $userids[$alert['userid']] = $alert['userid'];
             }
             if (isset($alert['hostid'])) {
                 $hostids[$alert['hostid']] = $alert['hostid'];
             }
             if (isset($alert['mediatypeid'])) {
                 $mediatypeids[$alert['mediatypeid']] = $alert['mediatypeid'];
             }
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$alert['alertid']] = array('alertid' => $alert['alertid']);
             } else {
                 if (!isset($result[$alert['alertid']])) {
                     $result[$alert['alertid']] = array();
                 }
                 if (!is_null($options['select_mediatypes']) && !isset($result[$alert['alertid']]['mediatypes'])) {
                     $result[$alert['alertid']]['mediatypes'] = array();
                 }
                 if (!is_null($options['select_users']) && !isset($result[$alert['alertid']]['users'])) {
                     $result[$alert['alertid']]['users'] = array();
                 }
                 // hostids
                 if (isset($alert['hostid']) && is_null($options['select_hosts'])) {
                     if (!isset($result[$alert['alertid']]['hosts'])) {
                         $result[$alert['alertid']]['hosts'] = array();
                     }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.calert.php

示例5: get


//.........这里部分代码省略.........
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'i');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     //----------
     $itemids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlGroup = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= ' AND ' . implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['group'])) {
         $sqlWhere .= ' GROUP BY ' . implode(',', $sqlParts['group']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     $sqlLimit = $sqlParts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . DBin_node('i.itemid', $nodeids) . $sqlWhere . $sqlGroup . $sqlOrder;
     //SDI($sql);
     $res = DBselect($sql, $sqlLimit);
     while ($item = DBfetch($res)) {
         if (!is_null($options['countOutput'])) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $item;
             } else {
                 $result = $item['rowscount'];
             }
         } else {
             $itemids[$item['itemid']] = $item['itemid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$item['itemid']] = array('itemid' => $item['itemid']);
             } else {
                 if (!isset($result[$item['itemid']])) {
                     $result[$item['itemid']] = array();
                 }
                 if (!is_null($options['selectHosts']) && !isset($result[$item['itemid']]['hosts'])) {
                     $result[$item['itemid']]['hosts'] = array();
                 }
                 if (!is_null($options['selectApplications']) && !isset($result[$item['itemid']]['applications'])) {
                     $result[$item['itemid']]['applications'] = array();
                 }
                 if (!is_null($options['selectTriggers']) && !isset($result[$item['itemid']]['triggers'])) {
                     $result[$item['itemid']]['triggers'] = array();
                 }
                 if (!is_null($options['selectGraphs']) && !isset($result[$item['itemid']]['graphs'])) {
                     $result[$item['itemid']]['graphs'] = array();
                 }
                 // hostids
                 if (isset($item['hostid']) && is_null($options['selectHosts'])) {
                     if (!isset($result[$item['itemid']]['hosts'])) {
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CItemPrototype.php

示例6: get


//.........这里部分代码省略.........
        if (is_array($options['search'])) {
            zbx_db_search('hosts h', $options, $sql_parts);
        }
        // extendoutput
        if ($options['output'] == API_OUTPUT_EXTEND) {
            $sql_parts['select']['hostid'] = 'h.hostid';
            $sql_parts['select']['host'] = 'h.host';
            $sql_parts['select']['status'] = 'h.status';
            $sql_parts['select']['lastaccess'] = 'h.lastaccess';
        }
        // countOutput
        if (!is_null($options['countOutput'])) {
            $options['sortfield'] = '';
            $sql_parts['select'] = array('count(DISTINCT h.hostid) as rowscount');
        }
        // order
        // restrict not allowed columns for sorting
        $options['sortfield'] = str_in_array($options['sortfield'], $sort_columns) ? $options['sortfield'] : '';
        if (!zbx_empty($options['sortfield'])) {
            $sortorder = $options['sortorder'] == ZBX_SORT_DOWN ? ZBX_SORT_DOWN : ZBX_SORT_UP;
            $sql_parts['order'][] = 'h.' . $options['sortfield'] . ' ' . $sortorder;
            if (!str_in_array('h.' . $options['sortfield'], $sql_parts['select']) && !str_in_array('h.*', $sql_parts['select'])) {
                $sql_parts['select'][] = 'h.' . $options['sortfield'];
            }
        }
        // limit
        if (zbx_ctype_digit($options['limit']) && $options['limit']) {
            $sql_parts['limit'] = $options['limit'];
        }
        //-------
        $proxyids = array();
        $sql_parts['select'] = array_unique($sql_parts['select']);
        $sql_parts['from'] = array_unique($sql_parts['from']);
        $sql_parts['where'] = array_unique($sql_parts['where']);
        $sql_parts['order'] = array_unique($sql_parts['order']);
        $sql_select = '';
        $sql_from = '';
        $sql_where = '';
        $sql_order = '';
        if (!empty($sql_parts['select'])) {
            $sql_select .= implode(',', $sql_parts['select']);
        }
        if (!empty($sql_parts['from'])) {
            $sql_from .= implode(',', $sql_parts['from']);
        }
        if (!empty($sql_parts['where'])) {
            $sql_where .= ' AND ' . implode(' AND ', $sql_parts['where']);
        }
        if (!empty($sql_parts['order'])) {
            $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
        }
        $sql_limit = $sql_parts['limit'];
        $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . '
				FROM ' . $sql_from . '
				WHERE ' . DBin_node('h.hostid', $nodeids) . $sql_where . $sql_order;
        // sdi($sql);
        $res = DBselect($sql, $sql_limit);
        while ($proxy = DBfetch($res)) {
            if ($options['countOutput']) {
                $result = $proxy['rowscount'];
            } else {
                $proxyids[$proxy['hostid']] = $proxy['hostid'];
                $proxy['proxyid'] = $proxy['hostid'];
                unset($proxy['hostid']);
                if ($options['output'] == API_OUTPUT_SHORTEN) {
                    $result[$proxy['proxyid']] = array('proxyid' => $proxy['proxyid']);
                } else {
                    if (!isset($result[$proxy['proxyid']])) {
                        $result[$proxy['proxyid']] = array();
                    }
                    if (!is_null($options['select_hosts']) && !isset($result[$proxy['proxyid']]['hosts'])) {
                        $result[$proxy['proxyid']]['hosts'] = array();
                    }
                    $result[$proxy['proxyid']] += $proxy;
                }
            }
        }
        if (!is_null($options['countOutput'])) {
            if (is_null($options['preservekeys'])) {
                $result = zbx_cleanHashes($result);
            }
            return $result;
        }
        // Adding Objects
        // select_hosts
        if (!empty($proxyids)) {
            if (!is_null($options['select_hosts']) && str_in_array($options['select_hosts'], $subselects_allowed_outputs)) {
                $obj_params = array('nodeids' => $nodeids, 'output' => $options['select_hosts'], 'proxyids' => $proxyids, 'preservekeys' => 1);
                $hosts = CHost::get($obj_params);
                foreach ($hosts as $host) {
                    $result[$host['proxy_hostid']]['hosts'][] = $host;
                }
            }
        }
        // removing keys (hash -> array)
        if (is_null($options['preservekeys'])) {
            $result = zbx_cleanHashes($result);
        }
        return $result;
    }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:class.cproxy.php

示例7: get


//.........这里部分代码省略.........
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 's');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $screenids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlGroup = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= ' AND ' . implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['group'])) {
         $sqlGroup .= ' GROUP BY ' . implode(',', $sqlParts['group']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     $sqlLimit = $sqlParts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . DBin_node('s.screenid', $nodeids) . $sqlWhere . $sqlGroup . $sqlOrder;
     $res = DBselect($sql, $sqlLimit);
     while ($screen = DBfetch($res)) {
         if (!is_null($options['countOutput'])) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $screen;
             } else {
                 $result = $screen['rowscount'];
             }
         } else {
             $screenids[$screen['screenid']] = $screen['screenid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$screen['screenid']] = array('screenid' => $screen['screenid'], 'templateid' => $screen['templateid']);
             } else {
                 if (!isset($result[$screen['screenid']])) {
                     $result[$screen['screenid']] = array();
                 }
                 if (!is_null($options['selectScreenItems']) && !isset($result[$screen['screenid']]['screenitems'])) {
                     $result[$screen['screenid']]['screenitems'] = array();
                 }
                 if (isset($screen['screenitemid']) && is_null($options['selectScreenItems'])) {
                     if (!isset($result[$screen['screenid']]['screenitems'])) {
                         $result[$screen['screenid']]['screenitems'] = array();
                     }
                     $result[$screen['screenid']]['screenitems'][] = array('screenitemid' => $screen['screenitemid']);
                     unset($screen['screenitemid']);
                 }
                 $result[$screen['screenid']] += $screen;
             }
         }
     }
     // hashing
     $options['hostids'] = zbx_toHash($options['hostids']);
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CTemplateScreen.php

示例8: get


//.........这里部分代码省略.........
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sql_parts['limit'] = $options['limit'];
     }
     //----------
     $itemids = array();
     $sql_parts['select'] = array_unique($sql_parts['select']);
     $sql_parts['from'] = array_unique($sql_parts['from']);
     $sql_parts['where'] = array_unique($sql_parts['where']);
     $sql_parts['group'] = array_unique($sql_parts['group']);
     $sql_parts['order'] = array_unique($sql_parts['order']);
     $sql_select = '';
     $sql_from = '';
     $sql_where = '';
     $sql_group = '';
     $sql_order = '';
     if (!empty($sql_parts['select'])) {
         $sql_select .= implode(',', $sql_parts['select']);
     }
     if (!empty($sql_parts['from'])) {
         $sql_from .= implode(',', $sql_parts['from']);
     }
     if (!empty($sql_parts['where'])) {
         $sql_where .= ' AND ' . implode(' AND ', $sql_parts['where']);
     }
     if (!empty($sql_parts['group'])) {
         $sql_where .= ' GROUP BY ' . implode(',', $sql_parts['group']);
     }
     if (!empty($sql_parts['order'])) {
         $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
     }
     $sql_limit = $sql_parts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . ' FROM ' . $sql_from . ' WHERE ' . DBin_node('i.itemid', $nodeids) . $sql_where . $sql_group . $sql_order;
     $res = DBselect($sql, $sql_limit);
     while ($item = DBfetch($res)) {
         if (!is_null($options['countOutput'])) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $item;
             } else {
                 $result = $item['rowscount'];
             }
         } else {
             $itemids[$item['itemid']] = $item['itemid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$item['itemid']] = array('itemid' => $item['itemid']);
             } else {
                 if (!isset($result[$item['itemid']])) {
                     $result[$item['itemid']] = array();
                 }
                 if (!is_null($options['select_hosts']) && !isset($result[$item['itemid']]['hosts'])) {
                     $result[$item['itemid']]['hosts'] = array();
                 }
                 if (!is_null($options['select_triggers']) && !isset($result[$item['itemid']]['triggers'])) {
                     $result[$item['itemid']]['triggers'] = array();
                 }
                 if (!is_null($options['select_graphs']) && !isset($result[$item['itemid']]['graphs'])) {
                     $result[$item['itemid']]['graphs'] = array();
                 }
                 if (!is_null($options['select_applications']) && !isset($result[$item['itemid']]['applications'])) {
                     $result[$item['itemid']]['applications'] = array();
                 }
                 // hostids
                 if (isset($item['hostid']) && is_null($options['select_hosts'])) {
                     if (!isset($result[$item['itemid']]['hosts'])) {
                         $result[$item['itemid']]['hosts'] = array();
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.citem.php

示例9: get

 /**
  * Get images data
  *
  * @param array $options
  * @param array $options['itemids']
  * @param array $options['hostids']
  * @param array $options['groupids']
  * @param array $options['triggerids']
  * @param array $options['imageids']
  * @param boolean $options['status']
  * @param boolean $options['editable']
  * @param boolean $options['count']
  * @param string $options['pattern']
  * @param int $options['limit']
  * @param string $options['order']
  * @return array|boolean image data as array or false if error
  */
 public function get($options = array())
 {
     $result = array();
     // allowed columns for sorting
     $sortColumns = array('imageid', 'name');
     $sqlParts = array('select' => array('images' => 'i.imageid'), 'from' => array('images' => 'images i'), 'where' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('nodeids' => null, 'imageids' => null, 'sysmapids' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_REFER, 'select_image' => null, 'editable' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
     $options = zbx_array_merge($defOptions, $options);
     // editable + PERMISSION CHECK
     if (!is_null($options['editable']) && self::$userData['type'] < USER_TYPE_ZABBIX_ADMIN) {
         return $result;
     }
     // nodeids
     $nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
     // imageids
     if (!is_null($options['imageids'])) {
         zbx_value2array($options['imageids']);
         $sqlParts['where']['imageid'] = dbConditionInt('i.imageid', $options['imageids']);
     }
     // sysmapids
     if (!is_null($options['sysmapids'])) {
         zbx_value2array($options['sysmapids']);
         $sqlParts['select']['sm'] = 'sm.sysmapid';
         $sqlParts['from']['sysmaps'] = 'sysmaps sm';
         $sqlParts['from']['sysmaps_elements'] = 'sysmaps_elements se';
         $sqlParts['where']['sm'] = dbConditionInt('sm.sysmapid', $options['sysmapids']);
         $sqlParts['where']['smse'] = 'sm.sysmapid=se.sysmapid ';
         $sqlParts['where']['se'] = '(' . 'se.iconid_off=i.imageid' . ' OR se.iconid_on=i.imageid' . ' OR se.iconid_disabled=i.imageid' . ' OR se.iconid_maintenance=i.imageid' . ' OR sm.backgroundid=i.imageid)';
     }
     // output
     if ($options['output'] == API_OUTPUT_EXTEND) {
         $sqlParts['select']['images'] = 'i.imageid, i.imagetype, i.name';
     }
     // count
     if (!is_null($options['countOutput'])) {
         $options['sortfield'] = '';
         $sqlParts['select'] = array('count(DISTINCT i.imageid) as rowscount');
     }
     // filter
     if (is_array($options['filter'])) {
         $this->dbFilter('images i', $options, $sqlParts);
     }
     // search
     if (is_array($options['search'])) {
         zbx_db_search('images i', $options, $sqlParts);
     }
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'i');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     $imageids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= ' AND ' . implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . DBin_node('i.imageid', $nodeids) . $sqlWhere . $sqlOrder;
     $res = DBselect($sql, $sqlParts['limit']);
     while ($image = DBfetch($res)) {
         if ($options['countOutput']) {
             return $image['rowscount'];
         } else {
             $imageids[$image['imageid']] = $image['imageid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$image['imageid']] = array('imageid' => $image['imageid']);
             } else {
//.........这里部分代码省略.........
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:101,代码来源:CImage.php

示例10: get


//.........这里部分代码省略.........
            if (!str_in_array('gm.' . $options['sortfield'], $sql_parts_global['select']) && !str_in_array('gm.*', $sql_parts_global['select'])) {
                $sql_parts_global['select'][] = 'gm.' . $options['sortfield'];
            }
        }
        // limit
        if (zbx_ctype_digit($options['limit']) && $options['limit']) {
            $sql_parts['limit'] = $options['limit'];
            $sql_parts_global['limit'] = $options['limit'];
        }
        //-------
        // init GLOBALS
        if (!is_null($options['globalmacro'])) {
            $sql_parts_global['select'] = array_unique($sql_parts_global['select']);
            $sql_parts_global['from'] = array_unique($sql_parts_global['from']);
            $sql_parts_global['where'] = array_unique($sql_parts_global['where']);
            $sql_parts_global['order'] = array_unique($sql_parts_global['order']);
            $sql_select = '';
            $sql_from = '';
            $sql_where = '';
            $sql_order = '';
            if (!empty($sql_parts_global['select'])) {
                $sql_select .= implode(',', $sql_parts_global['select']);
            }
            if (!empty($sql_parts_global['from'])) {
                $sql_from .= implode(',', $sql_parts_global['from']);
            }
            if (!empty($sql_parts_global['where'])) {
                $sql_where .= ' AND ' . implode(' AND ', $sql_parts_global['where']);
            }
            if (!empty($sql_parts_global['order'])) {
                $sql_order .= ' ORDER BY ' . implode(',', $sql_parts_global['order']);
            }
            $sql_limit = $sql_parts_global['limit'];
            $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . '
					FROM ' . $sql_from . '
					WHERE ' . DBin_node('gm.globalmacroid', $nodeids) . $sql_where . $sql_order;
            $res = DBselect($sql, $sql_limit);
            while ($macro = DBfetch($res)) {
                if ($options['countOutput']) {
                    $result = $macro['rowscount'];
                } else {
                    $globalmacroids[$macro['globalmacroid']] = $macro['globalmacroid'];
                    if ($options['output'] == API_OUTPUT_SHORTEN) {
                        $result[$macro['globalmacroid']] = array('globalmacroid' => $macro['globalmacroid']);
                    } else {
                        if (!isset($result[$macro['globalmacroid']])) {
                            $result[$macro['globalmacroid']] = array();
                        }
                        $result[$macro['globalmacroid']] += $macro;
                    }
                }
            }
        } else {
            $hostids = array();
            $sql_parts['select'] = array_unique($sql_parts['select']);
            $sql_parts['from'] = array_unique($sql_parts['from']);
            $sql_parts['where'] = array_unique($sql_parts['where']);
            $sql_parts['order'] = array_unique($sql_parts['order']);
            $sql_select = '';
            $sql_from = '';
            $sql_where = '';
            $sql_order = '';
            if (!empty($sql_parts['select'])) {
                $sql_select .= implode(',', $sql_parts['select']);
            }
            if (!empty($sql_parts['from'])) {
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.cusermacro.php

示例11: get


//.........这里部分代码省略.........
         $sql_parts['select']['key'] = 'i.key_';
         $sql_parts['select']['hostid'] = 'i.hostid';
         $sql_parts['select']['host'] = 'h.host';
         $sql_parts['from']['items'] = 'items i';
         $sql_parts['from']['hosts'] = 'hosts h';
         $sql_parts['where']['gii'] = 'gi.itemid=i.itemid';
         $sql_parts['where']['hi'] = 'h.hostid=i.hostid';
     }
     // countOutput
     if (!is_null($options['countOutput'])) {
         $options['sortfield'] = '';
         $sql_parts['select'] = array('count(DISTINCT gi.gitemid) as rowscount');
     }
     // order
     // restrict not allowed columns for sorting
     $options['sortfield'] = str_in_array($options['sortfield'], $sort_columns) ? $options['sortfield'] : '';
     if (!zbx_empty($options['sortfield'])) {
         $sortorder = $options['sortorder'] == ZBX_SORT_DOWN ? ZBX_SORT_DOWN : ZBX_SORT_UP;
         $sql_parts['order'][] = 'gi.' . $options['sortfield'] . ' ' . $sortorder;
         if (!str_in_array('gi.' . $options['sortfield'], $sql_parts['select']) && !str_in_array('gi.*', $sql_parts['select'])) {
             $sql_parts['select'][] = 'gi.' . $options['sortfield'];
         }
     }
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sql_parts['limit'] = $options['limit'];
     }
     //------------
     $gitemids = array();
     $sql_parts['select'] = array_unique($sql_parts['select']);
     $sql_parts['from'] = array_unique($sql_parts['from']);
     $sql_parts['where'] = array_unique($sql_parts['where']);
     $sql_parts['order'] = array_unique($sql_parts['order']);
     $sql_select = '';
     $sql_from = '';
     $sql_where = '';
     $sql_order = '';
     if (!empty($sql_parts['select'])) {
         $sql_select .= implode(',', $sql_parts['select']);
     }
     if (!empty($sql_parts['from'])) {
         $sql_from .= implode(',', $sql_parts['from']);
     }
     if (!empty($sql_parts['where'])) {
         $sql_where .= ' AND ' . implode(' AND ', $sql_parts['where']);
     }
     if (!empty($sql_parts['order'])) {
         $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
     }
     $sql_limit = $sql_parts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . ' FROM ' . $sql_from . ' WHERE ' . DBin_node('gi.gitemid', $nodeids) . $sql_where . $sql_order;
     //SDI($sql);
     $db_res = DBselect($sql, $sql_limit);
     while ($gitem = DBfetch($db_res)) {
         if (!is_null($options['countOutput'])) {
             $result = $gitem['rowscount'];
         } else {
             $gitemids[$gitem['gitemid']] = $gitem['gitemid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$gitem['gitemid']] = array('gitemid' => $gitem['gitemid']);
             } else {
                 if (!isset($result[$gitem['gitemid']])) {
                     $result[$gitem['gitemid']] = array();
                 }
                 // graphids
                 if (isset($gitem['graphid']) && is_null($options['select_graphs'])) {
                     if (!isset($result[$gitem['gitemid']]['graphs'])) {
                         $result[$gitem['gitemid']]['graphs'] = array();
                     }
                     $result[$gitem['gitemid']]['graphs'][] = array('graphid' => $gitem['graphid']);
                     //						unset($gitem['graphid']);
                 }
                 $result[$gitem['gitemid']] += $gitem;
             }
         }
     }
     if (!is_null($options['countOutput'])) {
         if (is_null($options['preservekeys'])) {
             $result = zbx_cleanHashes($result);
         }
         return $result;
     }
     // Adding graphs
     if (!is_null($options['select_graphs']) && str_in_array($options['select_graphs'], $subselects_allowed_outputs)) {
         $obj_params = array('nodeids' => $nodeids, 'output' => $options['select_graphs'], 'gitemids' => $gitemids, 'preservekeys' => 1);
         $graphs = CGraph::get($obj_params);
         foreach ($graphs as $graphid => $graph) {
             $gitems = $graph['gitems'];
             unset($graph['gitems']);
             foreach ($gitems as $inum => $item) {
                 $result[$gitem['gitemid']]['graphs'][] = $graph;
             }
         }
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:class.cgraphitem.php

示例12: get


//.........这里部分代码省略.........
            $sortorder = $options['sortorder'] == ZBX_SORT_DOWN ? ZBX_SORT_DOWN : ZBX_SORT_UP;
            $sql_parts['order'][] = 's.' . $options['sortfield'] . ' ' . $sortorder;
            if (!str_in_array('s.' . $options['sortfield'], $sql_parts['select']) && !str_in_array('s.*', $sql_parts['select'])) {
                $sql_parts['select'][] = 's.' . $options['sortfield'];
            }
        }
        // limit
        if (zbx_ctype_digit($options['limit']) && $options['limit']) {
            $sql_parts['limit'] = $options['limit'];
        }
        //-------
        $screenids = array();
        $sql_parts['select'] = array_unique($sql_parts['select']);
        $sql_parts['from'] = array_unique($sql_parts['from']);
        $sql_parts['where'] = array_unique($sql_parts['where']);
        $sql_parts['order'] = array_unique($sql_parts['order']);
        $sql_select = '';
        $sql_from = '';
        $sql_where = '';
        $sql_order = '';
        if (!empty($sql_parts['select'])) {
            $sql_select .= implode(',', $sql_parts['select']);
        }
        if (!empty($sql_parts['from'])) {
            $sql_from .= implode(',', $sql_parts['from']);
        }
        if (!empty($sql_parts['where'])) {
            $sql_where .= ' AND ' . implode(' AND ', $sql_parts['where']);
        }
        if (!empty($sql_parts['order'])) {
            $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
        }
        $sql_limit = $sql_parts['limit'];
        $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . '
				FROM ' . $sql_from . '
				WHERE ' . DBin_node('s.screenid', $nodeids) . $sql_where . $sql_order;
        $res = DBselect($sql, $sql_limit);
        while ($screen = DBfetch($res)) {
            if (!is_null($options['countOutput'])) {
                $result = $screen['rowscount'];
            } else {
                $screenids[$screen['screenid']] = $screen['screenid'];
                if ($options['output'] == API_OUTPUT_SHORTEN) {
                    $result[$screen['screenid']] = array('screenid' => $screen['screenid']);
                } else {
                    if (!isset($result[$screen['screenid']])) {
                        $result[$screen['screenid']] = array();
                    }
                    if (!is_null($options['select_screenitems']) && !isset($result[$screen['screenid']]['screenitems'])) {
                        $result[$screen['screenid']]['screenitems'] = array();
                    }
                    if (isset($screen['screenitemid']) && is_null($options['select_screenitems'])) {
                        if (!isset($result[$screen['screenid']]['screenitems'])) {
                            $result[$screen['screenid']]['screenitems'] = array();
                        }
                        $result[$screen['screenid']]['screenitems'][] = array('screenitemid' => $screen['screenitemid']);
                        unset($screen['screenitemid']);
                    }
                    $result[$screen['screenid']] += $screen;
                }
            }
        }
        if (USER_TYPE_SUPER_ADMIN == $user_type || $options['nopermissions']) {
        } else {
            if (!empty($result)) {
                $groups_to_check = array();
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.cscreen.php

示例13: getLinks


//.........这里部分代码省略.........
         zbx_value2array($options['linkids']);
         $sqlParts['where']['linkid'] = dbConditionInt('sl.linkid', $options['linkids']);
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sqlParts['where'][] = DBin_node('sl.linkid', $nodeids);
         }
     }
     // sysmapids
     if (!is_null($options['sysmapids'])) {
         zbx_value2array($options['sysmapids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sqlParts['select']['sysmapid'] = 'sl.sysmapid';
         }
         $sqlParts['where']['sysmapid'] = dbConditionInt('sl.sysmapid', $options['sysmapids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['sysmapid'] = 'sl.sysmapid';
         }
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sqlParts['where'][] = DBin_node('sl.sysmapid', $nodeids);
         }
     }
     // node check !!!!!
     // should last, after all ****IDS checks
     if (!$nodeCheck) {
         $nodeCheck = true;
         $sqlParts['where'][] = DBin_node('sl.linkid', $nodeids);
     }
     // search
     if (!is_null($options['search'])) {
         zbx_db_search('sysmaps_links sl', $options, $sqlParts);
     }
     // filter
     if (!is_null($options['filter'])) {
         $this->dbFilter('sysmaps_links sl', $options, $sqlParts);
     }
     // output
     if ($options['output'] == API_OUTPUT_EXTEND) {
         $sqlParts['select']['sysmaps'] = 'sl.*';
     }
     // countOutput
     if (!is_null($options['countOutput'])) {
         $options['sortfield'] = '';
         $sqlParts['select'] = array('count(DISTINCT s.sysmapid) as rowscount');
     }
     // sorting
     zbx_db_sorting($sqlParts, $options, $sortColumns, 'sl');
     // limit
     if (zbx_ctype_digit($options['limit']) && $options['limit']) {
         $sqlParts['limit'] = $options['limit'];
     }
     //-------
     $linkids = array();
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlGroup = '';
     $sqlOrder = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['group'])) {
         $sqlWhere .= ' GROUP BY ' . implode(',', $sqlParts['group']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     $sqlLimit = $sqlParts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . $sqlWhere . $sqlGroup . $sqlOrder;
     //SDI($sql);
     $res = DBselect($sql, $sqlLimit);
     while ($link = DBfetch($res)) {
         if ($options['countOutput']) {
             $result = $link['rowscount'];
         } else {
             $linkids[$link['linkid']] = $link['linkid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$link['linkid']] = array('linkid' => $link['linkid']);
             } else {
                 $result[$link['linkid']] = $link;
             }
         }
     }
     // removing keys (hash -> array)
     if (is_null($options['preservekeys'])) {
         $result = zbx_cleanHashes($result);
     }
     return $result;
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:101,代码来源:CMapElement.php

示例14: get


//.........这里部分代码省略.........
     if ($options['output'] != API_OUTPUT_EXTEND && (!is_null($options['selectHosts']) || !is_null($options['selectTriggers']) || !is_null($options['selectItems']))) {
         $sqlParts = $this->addQuerySelect($this->fieldId('object'), $sqlParts);
         $sqlParts = $this->addQuerySelect($this->fieldId('objectid'), $sqlParts);
     }
     $eventids = array();
     $triggerids = array();
     // event fields
     $sqlParts['select'] = array_unique($sqlParts['select']);
     $sqlParts['from'] = array_unique($sqlParts['from']);
     $sqlParts['where'] = array_unique($sqlParts['where']);
     $sqlParts['order'] = array_unique($sqlParts['order']);
     $sqlParts['group'] = array_unique($sqlParts['group']);
     $sqlSelect = '';
     $sqlFrom = '';
     $sqlWhere = '';
     $sqlOrder = '';
     $sqlGroup = '';
     if (!empty($sqlParts['select'])) {
         $sqlSelect .= implode(',', $sqlParts['select']);
     }
     if (!empty($sqlParts['from'])) {
         $sqlFrom .= implode(',', $sqlParts['from']);
     }
     if (!empty($sqlParts['where'])) {
         $sqlWhere .= implode(' AND ', $sqlParts['where']);
     }
     if (!empty($sqlParts['order'])) {
         $sqlOrder .= ' ORDER BY ' . implode(',', $sqlParts['order']);
     }
     if (!empty($sqlParts['group'])) {
         $sqlGroup .= ' GROUP BY ' . implode(',', $sqlParts['group']);
     }
     $sqlLimit = $sqlParts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sqlParts) . ' ' . $sqlSelect . ' FROM ' . $sqlFrom . ' WHERE ' . $sqlWhere . $sqlGroup . $sqlOrder;
     $dbRes = DBselect($sql, $sqlLimit);
     while ($event = DBfetch($dbRes)) {
         if (!is_null($options['countOutput'])) {
             if (!is_null($options['groupCount'])) {
                 $result[] = $event;
             } else {
                 $result = $event['rowscount'];
             }
         } else {
             $eventids[$event['eventid']] = $event['eventid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$event['eventid']] = array('eventid' => $event['eventid']);
             } else {
                 if (isset($event['object']) && $event['object'] == EVENT_OBJECT_TRIGGER) {
                     $triggerids[$event['objectid']] = $event['objectid'];
                 }
                 if (!isset($result[$event['eventid']])) {
                     $result[$event['eventid']] = array();
                 }
                 if (!is_null($options['selectHosts']) && !isset($result[$event['eventid']]['hosts'])) {
                     $result[$event['eventid']]['hosts'] = array();
                 }
                 if (!is_null($options['selectTriggers']) && !isset($result[$event['eventid']]['triggers'])) {
                     $result[$event['eventid']]['triggers'] = array();
                 }
                 if (!is_null($options['selectItems']) && !isset($result[$event['eventid']]['items'])) {
                     $result[$event['eventid']]['items'] = array();
                 }
                 if (!is_null($options['select_alerts']) && !isset($result[$event['eventid']]['alerts'])) {
                     $result[$event['eventid']]['alerts'] = array();
                 }
                 if (!is_null($options['select_acknowledges']) && !isset($result[$event['eventid']]['acknowledges'])) {
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CEvent.php

示例15: get


//.........这里部分代码省略.........
         $sql_parts['limit'] = $options['limit'];
     }
     // select_********
     if ($options['output'] != API_OUTPUT_EXTEND && (!is_null($options['select_hosts']) || !is_null($options['select_triggers']) || !is_null($options['select_items']))) {
         $sql_parts['select']['events'][] = 'e.object';
         $sql_parts['select']['events'][] = 'e.objectid';
     }
     //---------------
     $eventids = array();
     $triggerids = array();
     // Event fields
     $sql_parts['select']['events'] = implode(',', array_unique($sql_parts['select']['events']));
     $sql_parts['select'] = array_unique($sql_parts['select']);
     $sql_parts['from'] = array_unique($sql_parts['from']);
     $sql_parts['where'] = array_unique($sql_parts['where']);
     $sql_parts['order'] = array_unique($sql_parts['order']);
     $sql_select = '';
     $sql_from = '';
     $sql_where = '';
     $sql_order = '';
     if (!empty($sql_parts['select'])) {
         $sql_select .= implode(',', $sql_parts['select']);
     }
     if (!empty($sql_parts['from'])) {
         $sql_from .= implode(',', $sql_parts['from']);
     }
     if (!empty($sql_parts['where'])) {
         $sql_where .= implode(' AND ', $sql_parts['where']);
     }
     if (!empty($sql_parts['order'])) {
         $sql_order .= ' ORDER BY ' . implode(',', $sql_parts['order']);
     }
     $sql_limit = $sql_parts['limit'];
     $sql = 'SELECT ' . zbx_db_distinct($sql_parts) . ' ' . $sql_select . ' FROM ' . $sql_from . ' WHERE ' . $sql_where . $sql_order;
     $db_res = DBselect($sql, $sql_limit);
     //SDI($sql);
     while ($event = DBfetch($db_res)) {
         if ($options['countOutput']) {
             $result = $event['rowscount'];
         } else {
             $eventids[$event['eventid']] = $event['eventid'];
             if ($options['output'] == API_OUTPUT_SHORTEN) {
                 $result[$event['eventid']] = array('eventid' => $event['eventid']);
             } else {
                 if (isset($event['object']) && $event['object'] == EVENT_OBJECT_TRIGGER) {
                     $triggerids[$event['objectid']] = $event['objectid'];
                 }
                 if (!isset($result[$event['eventid']])) {
                     $result[$event['eventid']] = array();
                 }
                 if (!is_null($options['select_hosts']) && !isset($result[$event['eventid']]['hosts'])) {
                     $result[$event['eventid']]['hosts'] = array();
                 }
                 if (!is_null($options['select_triggers']) && !isset($result[$event['eventid']]['triggers'])) {
                     $result[$event['eventid']]['triggers'] = array();
                 }
                 if (!is_null($options['select_items']) && !isset($result[$event['eventid']]['items'])) {
                     $result[$event['eventid']]['items'] = array();
                 }
                 // hostids
                 if (isset($event['hostid']) && is_null($options['select_hosts'])) {
                     if (!isset($result[$event['eventid']]['hosts'])) {
                         $result[$event['eventid']]['hosts'] = array();
                     }
                     $result[$event['eventid']]['hosts'][] = array('hostid' => $event['hostid']);
                     unset($event['hostid']);
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:67,代码来源:class.cevent.php


注:本文中的zbx_db_distinct函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。