本文整理汇总了PHP中zbx_cleanHashes函数的典型用法代码示例。如果您正苦于以下问题:PHP zbx_cleanHashes函数的具体用法?PHP zbx_cleanHashes怎么用?PHP zbx_cleanHashes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zbx_cleanHashes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get services.
*
* Allowed options:
* - parentids - fetch the services that are hardlinked to the given parent services;
* - childids - fetch the services that are hardlinked to the given child services;
* - countOutput - return the number of the results as an integer;
* - selectParent - include the parent service in the result;
* - selectDependencies - include service child dependencies in the result;
* - selectParentDependencies - include service parent dependencies in the result;
* - selectTimes - include service times in the result;
* - selectAlarms - include alarms generated by the service;
* - selectTrigger - include the linked trigger;
* - sortfield - name of columns to sort by;
* - sortorder - sort order.
*
* @param array $options
*
* @return array
*/
public function get(array $options)
{
$options = zbx_array_merge($this->getOptions, $options);
// if the selectTrigger option is used, make sure we select the triggerid to be able to fetch the related triggers
if ($options['selectTrigger'] !== null) {
$options['output'] = $this->extendOutputOption($this->tableName(), 'triggerid', $options['output']);
}
// build and execute query
$sql = $this->createSelectQuery($this->tableName(), $options);
$res = DBselect($sql, $options['limit']);
// fetch results
$result = array();
while ($row = DBfetch($res)) {
// a count query, return a single result
if ($options['countOutput'] !== null) {
$result = $row['rowscount'];
} else {
$result[$row[$this->pk()]] = $this->unsetExtraFields($this->tableName(), $row, $options['output']);
}
}
if ($options['countOutput'] !== null) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
}
if ($options['preservekeys'] === null) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例2: get
/**
* Get value maps.
*
* @param array $options
*
* @return array
*/
public function get($options = [])
{
$options = zbx_array_merge($this->getOptions, $options);
if ($options['editable'] !== null && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
return $options['countOutput'] !== null && $options['groupCount'] === null ? 0 : [];
}
$res = DBselect($this->createSelectQuery($this->tableName(), $options), $options['limit']);
$result = [];
while ($row = DBfetch($res)) {
if ($options['countOutput'] === null) {
$result[$row[$this->pk()]] = $row;
} else {
if ($options['groupCount'] === null) {
$result = $row['rowscount'];
} else {
$result[] = $row;
}
}
}
if ($options['countOutput'] !== null) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
}
// removing keys (hash -> array)
if ($options['preservekeys'] === null) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例3: get
/**
* Get host prototypes.
*
* @param array $options
*
* @return array
*/
public function get(array $options)
{
$options = zbx_array_merge($this->getOptions, $options);
$options['filter']['flags'] = ZBX_FLAG_DISCOVERY_PROTOTYPE;
// build and execute query
$sql = $this->createSelectQuery($this->tableName(), $options);
$res = DBselect($sql, $options['limit']);
// fetch results
$result = [];
while ($row = DBfetch($res)) {
// a count query, return a single result
if ($options['countOutput'] !== null) {
if ($options['groupCount'] !== null) {
$result[] = $row;
} else {
$result = $row['rowscount'];
}
} else {
$result[$row[$this->pk()]] = $row;
}
}
if ($options['countOutput'] !== null) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
$result = $this->unsetExtraFields($result, ['triggerid'], $options['output']);
}
if ($options['preservekeys'] === null) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例4: __construct
/**
* @param array $options['objectOptions'] an array of parameters to be added to the request URL
*
* @see jQuery.multiSelect()
*/
public function __construct(array $options = [])
{
parent::__construct('div', true);
$this->addClass('multiselect');
$this->setId(zbx_formatDomId($options['name']));
// url
$url = new CUrl('jsrpc.php');
$url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON);
$url->setArgument('method', 'multiselect.get');
$url->setArgument('objectName', $options['objectName']);
if (!empty($options['objectOptions'])) {
foreach ($options['objectOptions'] as $optionName => $optionvalue) {
$url->setArgument($optionName, $optionvalue);
}
}
$params = ['url' => $url->getUrl(), 'name' => $options['name'], 'labels' => ['No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')]];
if (array_key_exists('data', $options)) {
$params['data'] = zbx_cleanHashes($options['data']);
}
foreach (['ignored', 'defaultValue', 'disabled', 'selectedLimit', 'addNew'] as $option) {
if (array_key_exists($option, $options)) {
$params[$option] = $options[$option];
}
}
if (array_key_exists('popup', $options)) {
foreach (['parameters', 'width', 'height'] as $option) {
if (array_key_exists($option, $options['popup'])) {
$params['popup'][$option] = $options['popup'][$option];
}
}
}
zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ');');
}
示例5: __construct
/**
* @param array $options['objectOptions'] an array of parameters to be added to the request URL
*
* @see jQuery.multiSelect()
*/
public function __construct(array $options = array())
{
parent::__construct('div', 'yes');
$this->addClass('multiselect');
$this->attr('id', zbx_formatDomId($options['name']));
// url
$url = new Curl('jsrpc.php');
$url->setArgument('type', PAGE_TYPE_TEXT_RETURN_JSON);
$url->setArgument('method', 'multiselect.get');
$url->setArgument('objectName', $options['objectName']);
if (!empty($options['objectOptions'])) {
foreach ($options['objectOptions'] as $optionName => $optionvalue) {
$url->setArgument($optionName, $optionvalue);
}
}
$params = array('id' => $this->getAttribute('id'), 'url' => $url->getUrl(), 'name' => $options['name'], 'labels' => array('No matches found' => _('No matches found'), 'More matches found...' => _('More matches found...'), 'type here to search' => _('type here to search'), 'new' => _('new'), 'Select' => _('Select')), 'data' => empty($options['data']) ? array() : zbx_cleanHashes($options['data']), 'ignored' => isset($options['ignored']) ? $options['ignored'] : null, 'defaultValue' => isset($options['defaultValue']) ? $options['defaultValue'] : null, 'disabled' => isset($options['disabled']) ? $options['disabled'] : false, 'selectedLimit' => isset($options['selectedLimit']) ? $options['selectedLimit'] : null, 'addNew' => isset($options['addNew']) ? $options['addNew'] : false, 'popup' => array('parameters' => isset($options['popup']['parameters']) ? $options['popup']['parameters'] : null, 'width' => isset($options['popup']['width']) ? $options['popup']['width'] : null, 'height' => isset($options['popup']['height']) ? $options['popup']['height'] : null, 'buttonClass' => isset($options['popup']['buttonClass']) ? $options['popup']['buttonClass'] : null));
zbx_add_post_js('jQuery("#' . $this->getAttribute('id') . '").multiSelect(' . CJs::encodeJson($params) . ')');
}
示例6: get
//.........这里部分代码省略.........
* @return array
*/
public function get(array $options = [])
{
$result = [];
$userType = self::$userData['type'];
$userid = self::$userData['userid'];
$sqlParts = ['select' => ['maintenance' => 'm.maintenanceid'], 'from' => ['maintenances' => 'maintenances m'], 'where' => [], 'group' => [], 'order' => [], 'limit' => null];
$defOptions = ['groupids' => null, 'hostids' => null, 'maintenanceids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'filter' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectGroups' => null, 'selectHosts' => null, 'selectTimeperiods' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null];
$options = zbx_array_merge($defOptions, $options);
// editable + PERMISSION CHECK
$maintenanceids = [];
if ($userType == USER_TYPE_SUPER_ADMIN || $options['nopermissions']) {
if (!is_null($options['groupids']) || !is_null($options['hostids'])) {
if (!is_null($options['groupids'])) {
zbx_value2array($options['groupids']);
$res = DBselect('SELECT mmg.maintenanceid' . ' FROM maintenances_groups mmg' . ' WHERE ' . dbConditionInt('mmg.groupid', $options['groupids']));
while ($maintenance = DBfetch($res)) {
$maintenanceids[] = $maintenance['maintenanceid'];
}
}
$sql = 'SELECT mmh.maintenanceid' . ' FROM maintenances_hosts mmh,hosts_groups hg' . ' WHERE hg.hostid=mmh.hostid';
if (!is_null($options['groupids'])) {
zbx_value2array($options['groupids']);
$sql .= ' AND ' . dbConditionInt('hg.groupid', $options['groupids']);
}
if (!is_null($options['hostids'])) {
zbx_value2array($options['hostids']);
$sql .= ' AND ' . dbConditionInt('hg.hostid', $options['hostids']);
}
$res = DBselect($sql);
while ($maintenance = DBfetch($res)) {
$maintenanceids[] = $maintenance['maintenanceid'];
}
$sqlParts['where'][] = dbConditionInt('m.maintenanceid', $maintenanceids);
}
} else {
$permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ;
$userGroups = getUserGroupsByUserId($userid);
$sql = 'SELECT m.maintenanceid' . ' FROM maintenances m' . ' WHERE NOT EXISTS (' . 'SELECT NULL' . ' FROM maintenances_hosts mh,hosts_groups hg' . ' LEFT JOIN rights r' . ' ON r.id=hg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE m.maintenanceid=mh.maintenanceid' . ' AND mh.hostid=hg.hostid' . ' GROUP by mh.hostid' . ' HAVING MIN(r.permission) IS NULL' . ' OR MIN(r.permission)=' . PERM_DENY . ' OR MAX(r.permission)<' . zbx_dbstr($permission) . ')' . ' AND NOT EXISTS (' . 'SELECT NULL' . ' FROM maintenances_groups mg' . ' LEFT JOIN rights r' . ' ON r.id=mg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE m.maintenanceid=mg.maintenanceid' . ' GROUP by mg.groupid' . ' HAVING MIN(r.permission) IS NULL' . ' OR MIN(r.permission)=' . PERM_DENY . ' OR MAX(r.permission)<' . zbx_dbstr($permission) . ')';
if (!is_null($options['groupids'])) {
zbx_value2array($options['groupids']);
$sql .= ' AND (' . 'EXISTS (' . 'SELECT NULL' . ' FROM maintenances_groups mg' . ' WHERE m.maintenanceid=mg.maintenanceid' . ' AND ' . dbConditionInt('mg.groupid', $options['groupids']) . ')' . ' OR EXISTS (' . 'SELECT NULL' . ' FROM maintenances_hosts mh,hosts_groups hg' . ' WHERE m.maintenanceid=mh.maintenanceid' . ' AND mh.hostid=hg.hostid' . ' AND ' . dbConditionInt('hg.groupid', $options['groupids']) . ')' . ')';
}
if (!is_null($options['hostids'])) {
zbx_value2array($options['hostids']);
$sql .= ' AND EXISTS (' . 'SELECT NULL' . ' FROM maintenances_hosts mh' . ' WHERE m.maintenanceid=mh.maintenanceid' . ' AND ' . dbConditionInt('mh.hostid', $options['hostids']) . ')';
}
if (!is_null($options['maintenanceids'])) {
zbx_value2array($options['maintenanceids']);
$sql .= ' AND ' . dbConditionInt('m.maintenanceid', $options['maintenanceids']);
}
$res = DBselect($sql);
while ($maintenance = DBfetch($res)) {
$maintenanceids[] = $maintenance['maintenanceid'];
}
$sqlParts['where'][] = dbConditionInt('m.maintenanceid', $maintenanceids);
}
// maintenanceids
if (!is_null($options['maintenanceids'])) {
zbx_value2array($options['maintenanceids']);
$sqlParts['where'][] = dbConditionInt('m.maintenanceid', $options['maintenanceids']);
}
// filter
if (is_array($options['filter'])) {
$this->dbFilter('maintenances m', $options, $sqlParts);
}
// search
if (is_array($options['search'])) {
zbx_db_search('maintenances m', $options, $sqlParts);
}
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sqlParts['limit'] = $options['limit'];
}
$sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
while ($maintenance = DBfetch($res)) {
if (!is_null($options['countOutput'])) {
if (!is_null($options['groupCount'])) {
$result[] = $maintenance;
} else {
$result = $maintenance['rowscount'];
}
} else {
$result[$maintenance['maintenanceid']] = $maintenance;
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
}
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例7: get
//.........这里部分代码省略.........
$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('a.applicationid', $nodeids) . $sqlWhere . $sqlGroup . $sqlOrder;
$res = DBselect($sql, $sqlLimit);
while ($application = DBfetch($res)) {
if (!is_null($options['countOutput'])) {
if (!is_null($options['groupCount'])) {
$result[] = $application;
} else {
$result = $application['rowscount'];
}
} else {
$applicationids[$application['applicationid']] = $application['applicationid'];
if ($options['output'] == API_OUTPUT_SHORTEN) {
$result[$application['applicationid']] = array('applicationid' => $application['applicationid']);
} else {
if (!isset($result[$application['applicationid']])) {
$result[$application['applicationid']] = array();
}
if (!is_null($options['selectHosts']) && !isset($result[$application['applicationid']]['hosts'])) {
$result[$application['applicationid']]['hosts'] = array();
}
if (!is_null($options['selectItems']) && !isset($result[$application['applicationid']]['items'])) {
$result[$application['applicationid']]['items'] = array();
}
// hostids
if (isset($application['hostid']) && is_null($options['selectHosts'])) {
if (!isset($result[$application['applicationid']]['hosts'])) {
$result[$application['applicationid']]['hosts'] = array();
}
$result[$application['applicationid']]['hosts'][] = array('hostid' => $application['hostid']);
}
// itemids
if (isset($application['itemid']) && is_null($options['selectItems'])) {
if (!isset($result[$application['applicationid']]['items'])) {
$result[$application['applicationid']]['items'] = array();
}
$result[$application['applicationid']]['items'][] = array('itemid' => $application['itemid']);
unset($application['itemid']);
}
$result[$application['applicationid']] += $application;
}
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
// adding objects
// adding hosts
if ($options['selectHosts'] !== null && (is_array($options['selectHosts']) || str_in_array($options['selectHosts'], $subselectsAllowedOutputs))) {
$objParams = array('output' => $options['selectHosts'], 'applicationids' => $applicationids, 'nopermissions' => 1, 'templated_hosts' => true, 'preservekeys' => 1);
$hosts = API::Host()->get($objParams);
foreach ($hosts as $hostid => $host) {
$iapplications = $host['applications'];
unset($host['applications']);
foreach ($iapplications as $application) {
$result[$application['applicationid']]['hosts'][] = $host;
}
}
}
// adding objects
// adding items
if (!is_null($options['selectItems']) && str_in_array($options['selectItems'], $subselectsAllowedOutputs)) {
$objParams = array('output' => $options['selectItems'], 'applicationids' => $applicationids, 'nopermissions' => true, 'preservekeys' => true);
$items = API::Item()->get($objParams);
foreach ($items as $itemid => $item) {
$iapplications = $item['applications'];
unset($item['applications']);
foreach ($iapplications as $application) {
$result[$application['applicationid']]['items'][] = $item;
}
}
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例8: get
/**
* Get scripts data.
*
* @param array $options
* @param array $options['itemids']
* @param array $options['hostids'] deprecated (very slow)
* @param array $options['groupids']
* @param array $options['triggerids']
* @param array $options['scriptids']
* @param bool $options['status']
* @param bool $options['editable']
* @param bool $options['count']
* @param string $options['pattern']
* @param int $options['limit']
* @param string $options['order']
*
* @return array
*/
public function get(array $options)
{
$result = array();
$userType = self::$userData['type'];
$userid = self::$userData['userid'];
$sqlParts = array('select' => array('scripts' => 's.scriptid'), 'from' => array('scripts s'), 'where' => array(), 'order' => array(), 'limit' => null);
$defOptions = array('groupids' => null, 'hostids' => null, 'scriptids' => null, 'usrgrpids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectGroups' => null, 'selectHosts' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
$options = zbx_array_merge($defOptions, $options);
// editable + permission check
if ($userType != USER_TYPE_SUPER_ADMIN) {
if (!is_null($options['editable'])) {
return $result;
}
$userGroups = getUserGroupsByUserId($userid);
$sqlParts['where'][] = '(s.usrgrpid IS NULL OR ' . dbConditionInt('s.usrgrpid', $userGroups) . ')';
$sqlParts['where'][] = '(s.groupid IS NULL OR EXISTS (' . 'SELECT NULL' . ' FROM rights r' . ' WHERE s.groupid=r.id' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' GROUP BY r.id' . ' HAVING MIN(r.permission)>' . PERM_DENY . '))';
}
// groupids
if (!is_null($options['groupids'])) {
zbx_value2array($options['groupids']);
$sqlParts['where'][] = '(s.groupid IS NULL OR ' . dbConditionInt('s.groupid', $options['groupids']) . ')';
}
// hostids
if (!is_null($options['hostids'])) {
zbx_value2array($options['hostids']);
// return scripts that are assigned to the hosts' groups or to no group
$hostGroups = API::HostGroup()->get(array('output' => array('groupid'), 'hostids' => $options['hostids']));
$hostGroupIds = zbx_objectValues($hostGroups, 'groupid');
$sqlParts['where'][] = '(' . dbConditionInt('s.groupid', $hostGroupIds) . ' OR s.groupid IS NULL)';
}
// usrgrpids
if (!is_null($options['usrgrpids'])) {
zbx_value2array($options['usrgrpids']);
$sqlParts['where'][] = '(s.usrgrpid IS NULL OR ' . dbConditionInt('s.usrgrpid', $options['usrgrpids']) . ')';
}
// scriptids
if (!is_null($options['scriptids'])) {
zbx_value2array($options['scriptids']);
$sqlParts['where'][] = dbConditionInt('s.scriptid', $options['scriptids']);
}
// search
if (is_array($options['search'])) {
zbx_db_search('scripts s', $options, $sqlParts);
}
// filter
if (is_array($options['filter'])) {
$this->dbFilter('scripts s', $options, $sqlParts);
}
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sqlParts['limit'] = $options['limit'];
}
$sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
while ($script = DBfetch($res)) {
if ($options['countOutput']) {
$result = $script['rowscount'];
} else {
$result[$script['scriptid']] = $script;
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
$result = $this->unsetExtraFields($result, array('groupid', 'host_access'), $options['output']);
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例9: get
/**
* Get IconMap data.
* @param array $options
* @param array $options['iconmapids']
* @param array $options['sysmapids']
* @param array $options['editable']
* @param array $options['count']
* @param array $options['limit']
* @param array $options['order']
* @return array
*/
public function get(array $options = [])
{
$result = [];
$sqlParts = ['select' => ['icon_map' => 'im.iconmapid'], 'from' => ['icon_map' => 'icon_map im'], 'where' => [], 'order' => [], 'limit' => null];
$defOptions = ['iconmapids' => null, 'sysmapids' => null, 'nopermissions' => null, 'editable' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_EXTEND, 'selectMappings' => null, 'countOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null];
$options = zbx_array_merge($defOptions, $options);
// editable + PERMISSION CHECK
if ($options['editable'] && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
return [];
}
// iconmapids
if (!is_null($options['iconmapids'])) {
zbx_value2array($options['iconmapids']);
$sqlParts['where'][] = dbConditionInt('im.iconmapid', $options['iconmapids']);
}
// sysmapids
if (!is_null($options['sysmapids'])) {
zbx_value2array($options['sysmapids']);
$sqlParts['from']['sysmaps'] = 'sysmaps s';
$sqlParts['where'][] = dbConditionInt('s.sysmapid', $options['sysmapids']);
$sqlParts['where']['ims'] = 'im.iconmapid=s.iconmapid';
}
// filter
if (is_array($options['filter'])) {
$this->dbFilter('icon_map im', $options, $sqlParts);
}
// search
if (is_array($options['search'])) {
zbx_db_search('icon_map im', $options, $sqlParts);
}
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sqlParts['limit'] = $options['limit'];
}
$sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
while ($iconMap = DBfetch($dbRes)) {
if ($options['countOutput']) {
$result = $iconMap['rowscount'];
} else {
$result[$iconMap['iconmapid']] = $iconMap;
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例10: get
//.........这里部分代码省略.........
if (!is_null($options['groupOutput'])) {
if (str_in_array('h.' . $options['groupOutput'], $sql_parts['select']) || str_in_array('h.*', $sql_parts['select'])) {
$groupOutput = true;
}
}
// 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;
if ($options['sortfield'] == 'clock') {
$sql_parts['order']['itemid'] = 'h.itemid ' . $sortorder;
}
$sql_parts['order'][$options['sortfield']] = 'h.' . $options['sortfield'] . ' ' . $sortorder;
if (!str_in_array('h.' . $options['sortfield'], $sql_parts['select']) && !str_in_array('h.*', $sql_parts['select'])) {
$sql_parts['select'][$options['sortfield']] = 'h.' . $options['sortfield'];
}
}
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sql_parts['limit'] = $options['limit'];
}
//---------------
$itemids = array();
$triggerids = 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 .= 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 ' . $sql_select . ' FROM ' . $sql_from . ' WHERE ' . $sql_where . $sql_order;
$db_res = DBselect($sql, $sql_limit);
//SDI($sql);
$count = 0;
$group = array();
while ($data = DBfetch($db_res)) {
if ($options['countOutput']) {
$result = $data;
} else {
$itemids[$data['itemid']] = $data['itemid'];
if ($options['output'] == API_OUTPUT_SHORTEN) {
$result[$count] = array('itemid' => $data['itemid']);
} else {
$result[$count] = array();
// hostids
if (isset($data['hostid'])) {
if (!isset($result[$count]['hosts'])) {
$result[$count]['hosts'] = array();
}
$result[$count]['hosts'][] = array('hostid' => $data['hostid']);
unset($data['hostid']);
}
// triggerids
if (isset($data['triggerid'])) {
if (!isset($result[$count]['triggers'])) {
$result[$count]['triggers'] = array();
}
$result[$count]['triggers'][] = array('triggerid' => $data['triggerid']);
unset($data['triggerid']);
}
// itemids
// if(isset($data['itemid']) && !is_null($options['itemids'])){
// if(!isset($result[$count]['items'])) $result[$count]['items'] = array();
// $result[$count]['items'][] = array('itemid' => $data['itemid']);
// }
$result[$count] += $data;
// grouping
if ($groupOutput) {
$dataid = $data[$options['groupOutput']];
if (!isset($group[$dataid])) {
$group[$dataid] = array();
}
$group[$dataid][] = $result[$count];
}
$count++;
}
}
}
COpt::memoryPick();
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例11: get
//.........这里部分代码省略.........
}
$result[$dservice['dserviceid']]['drules'][] =& $drules[$druleid];
}
}
} elseif (API_OUTPUT_COUNT == $options['selectDRules']) {
$objParams['countOutput'] = 1;
$objParams['groupCount'] = 1;
$drules = API::DRule()->get($objParams);
$drules = zbx_toHash($drules, 'dserviceid');
foreach ($result as $dserviceid => $dservice) {
if (isset($drules[$dserviceid])) {
$result[$dserviceid]['drules'] = $drules[$dserviceid]['rowscount'];
} else {
$result[$dserviceid]['drules'] = 0;
}
}
}
}
// selectDHosts
if (!is_null($options['selectDHosts'])) {
$objParams = array('nodeids' => $nodeids, 'dserviceids' => $dserviceids, 'preservekeys' => 1);
if (is_array($options['selectDHosts']) || str_in_array($options['selectDHosts'], $subselectsAllowedOutputs)) {
$objParams['output'] = $options['selectDHosts'];
$dhosts = API::DHost()->get($objParams);
if (!is_null($options['limitSelects'])) {
order_result($dhosts, 'dhostid');
}
foreach ($dhosts as $dhostid => $dhost) {
unset($dhosts[$dhostid]['dservices']);
foreach ($dhost['dservices'] as $snum => $dservice) {
if (!is_null($options['limitSelects'])) {
if (!isset($count[$dservice['dserviceid']])) {
$count[$dservice['dserviceid']] = 0;
}
$count[$dservice['dserviceid']]++;
if ($count[$dservice['dserviceid']] > $options['limitSelects']) {
continue;
}
}
$result[$dservice['dserviceid']]['dhosts'][] =& $dhosts[$dhostid];
}
}
} elseif (API_OUTPUT_COUNT == $options['selectDHosts']) {
$objParams['countOutput'] = 1;
$objParams['groupCount'] = 1;
$dhosts = API::DHost()->get($objParams);
$dhosts = zbx_toHash($dhosts, 'dhostid');
foreach ($result as $dserviceid => $dservice) {
if (isset($dhosts[$dserviceid])) {
$result[$dserviceid]['dhosts'] = $dhosts[$dserviceid]['rowscount'];
} else {
$result[$dserviceid]['dhosts'] = 0;
}
}
}
}
// selectHosts
if (!is_null($options['selectHosts'])) {
$objParams = array('nodeids' => $nodeids, 'dserviceids' => $dserviceids, 'preservekeys' => 1, 'sortfield' => 'status');
if (is_array($options['selectHosts']) || str_in_array($options['selectHosts'], $subselectsAllowedOutputs)) {
$objParams['output'] = $options['selectHosts'];
$hosts = API::Host()->get($objParams);
if (!is_null($options['limitSelects'])) {
order_result($hosts, 'hostid');
}
foreach ($hosts as $hostid => $host) {
unset($hosts[$hostid]['dservices']);
foreach ($host['dservices'] as $dnum => $dservice) {
if (!is_null($options['limitSelects'])) {
if (!isset($count[$dservice['dserviceid']])) {
$count[$dservice['dserviceid']] = 0;
}
$count[$dservice['dserviceid']]++;
if ($count[$dservice['dserviceid']] > $options['limitSelects']) {
continue;
}
}
$result[$dservice['dserviceid']]['hosts'][] =& $hosts[$hostid];
}
}
} elseif (API_OUTPUT_COUNT == $options['selectHosts']) {
$objParams['countOutput'] = 1;
$objParams['groupCount'] = 1;
$hosts = API::Host()->get($objParams);
$hosts = zbx_toHash($hosts, 'hostid');
foreach ($result as $dserviceid => $dservice) {
if (isset($hosts[$dserviceid])) {
$result[$dserviceid]['hosts'] = $hosts[$dserviceid]['rowscount'];
} else {
$result[$dserviceid]['hosts'] = 0;
}
}
}
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例12: get
//.........这里部分代码省略.........
$sqlParts['where']['hg'] = dbConditionInt('hg.groupid', $options['groupids']);
$sqlParts['where']['hgi'] = 'hg.hostid=i.hostid';
$sqlParts['where']['fe'] = 'f.triggerid=e.objectid';
$sqlParts['where']['fi'] = 'f.itemid=i.itemid';
} elseif ($options['object'] == EVENT_OBJECT_LLDRULE || $options['object'] == EVENT_OBJECT_ITEM) {
$sqlParts['from']['items'] = 'items i';
$sqlParts['from']['hosts_groups'] = 'hosts_groups hg';
$sqlParts['where']['hg'] = dbConditionInt('hg.groupid', $options['groupids']);
$sqlParts['where']['hgi'] = 'hg.hostid=i.hostid';
$sqlParts['where']['fi'] = 'e.objectid=i.itemid';
}
}
// hostids
if (!is_null($options['hostids'])) {
zbx_value2array($options['hostids']);
// triggers
if ($options['object'] == EVENT_OBJECT_TRIGGER) {
$sqlParts['from']['functions'] = 'functions f';
$sqlParts['from']['items'] = 'items i';
$sqlParts['where']['i'] = dbConditionInt('i.hostid', $options['hostids']);
$sqlParts['where']['ft'] = 'f.triggerid=e.objectid';
$sqlParts['where']['fi'] = 'f.itemid=i.itemid';
} elseif ($options['object'] == EVENT_OBJECT_LLDRULE || $options['object'] == EVENT_OBJECT_ITEM) {
$sqlParts['from']['items'] = 'items i';
$sqlParts['where']['i'] = dbConditionInt('i.hostid', $options['hostids']);
$sqlParts['where']['fi'] = 'e.objectid=i.itemid';
}
}
// object
if (!is_null($options['object'])) {
$sqlParts['where']['o'] = 'e.object=' . zbx_dbstr($options['object']);
}
// source
if (!is_null($options['source'])) {
$sqlParts['where'][] = 'e.source=' . zbx_dbstr($options['source']);
}
// acknowledged
if (!is_null($options['acknowledged'])) {
$sqlParts['where'][] = 'e.acknowledged=' . ($options['acknowledged'] ? 1 : 0);
}
// time_from
if (!is_null($options['time_from'])) {
$sqlParts['where'][] = 'e.clock>=' . zbx_dbstr($options['time_from']);
}
// time_till
if (!is_null($options['time_till'])) {
$sqlParts['where'][] = 'e.clock<=' . zbx_dbstr($options['time_till']);
}
// eventid_from
if (!is_null($options['eventid_from'])) {
$sqlParts['where'][] = 'e.eventid>=' . zbx_dbstr($options['eventid_from']);
}
// eventid_till
if (!is_null($options['eventid_till'])) {
$sqlParts['where'][] = 'e.eventid<=' . zbx_dbstr($options['eventid_till']);
}
// value
if (!is_null($options['value'])) {
zbx_value2array($options['value']);
$sqlParts['where'][] = dbConditionInt('e.value', $options['value']);
}
// search
if (is_array($options['search'])) {
zbx_db_search('events e', $options, $sqlParts);
}
// filter
if (is_array($options['filter'])) {
$this->dbFilter('events e', $options, $sqlParts);
}
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sqlParts['limit'] = $options['limit'];
}
$sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
while ($event = DBfetch($res)) {
if (!is_null($options['countOutput'])) {
if (!is_null($options['groupCount'])) {
$result[] = $event;
} else {
$result = $event['rowscount'];
}
} else {
$result[$event['eventid']] = $event;
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
$result = $this->unsetExtraFields($result, array('object', 'objectid'), $options['output']);
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例13: get
//.........这里部分代码省略.........
// itemids
if (!is_null($options['itemids'])) {
zbx_value2array($options['itemids']);
$sqlParts['from']['graphs_items'] = 'graphs_items gi';
$sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
$sqlParts['where'][] = dbConditionInt('gi.itemid', $options['itemids']);
if (!is_null($options['groupCount'])) {
$sqlParts['group']['gi'] = 'gi.itemid';
}
}
// discoveryids
if (!is_null($options['discoveryids'])) {
zbx_value2array($options['discoveryids']);
$sqlParts['from']['graphs_items'] = 'graphs_items gi';
$sqlParts['from']['item_discovery'] = 'item_discovery id';
$sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
$sqlParts['where']['giid'] = 'gi.itemid=id.itemid';
$sqlParts['where'][] = dbConditionInt('id.parent_itemid', $options['discoveryids']);
if (!is_null($options['groupCount'])) {
$sqlParts['group']['id'] = 'id.parent_itemid';
}
}
// templated
if (!is_null($options['templated'])) {
$sqlParts['from']['graphs_items'] = 'graphs_items gi';
$sqlParts['from']['items'] = 'items i';
$sqlParts['from']['hosts'] = 'hosts h';
$sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
$sqlParts['where']['ggi'] = 'g.graphid=gi.graphid';
$sqlParts['where']['hi'] = 'h.hostid=i.hostid';
if ($options['templated']) {
$sqlParts['where'][] = 'h.status=' . HOST_STATUS_TEMPLATE;
} else {
$sqlParts['where'][] = 'h.status<>' . HOST_STATUS_TEMPLATE;
}
}
// inherited
if (!is_null($options['inherited'])) {
if ($options['inherited']) {
$sqlParts['where'][] = 'g.templateid IS NOT NULL';
} else {
$sqlParts['where'][] = 'g.templateid IS NULL';
}
}
// search
if (is_array($options['search'])) {
zbx_db_search('graphs g', $options, $sqlParts);
}
// filter
if (is_array($options['filter'])) {
$this->dbFilter('graphs g', $options, $sqlParts);
if (isset($options['filter']['host'])) {
zbx_value2array($options['filter']['host']);
$sqlParts['from']['graphs_items'] = 'graphs_items gi';
$sqlParts['from']['items'] = 'items i';
$sqlParts['from']['hosts'] = 'hosts h';
$sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
$sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
$sqlParts['where']['hi'] = 'h.hostid=i.hostid';
$sqlParts['where']['host'] = dbConditionString('h.host', $options['filter']['host']);
}
if (isset($options['filter']['hostid'])) {
zbx_value2array($options['filter']['hostid']);
$sqlParts['from']['graphs_items'] = 'graphs_items gi';
$sqlParts['from']['items'] = 'items i';
$sqlParts['where']['gig'] = 'gi.graphid=g.graphid';
$sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
$sqlParts['where']['hostid'] = dbConditionInt('i.hostid', $options['filter']['hostid']);
}
}
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sqlParts['limit'] = $options['limit'];
}
$sqlParts = $this->applyQueryOutputOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$sqlParts = $this->applyQuerySortOptions($this->tableName(), $this->tableAlias(), $options, $sqlParts);
$dbRes = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
while ($graph = DBfetch($dbRes)) {
if (!is_null($options['countOutput'])) {
if (!is_null($options['groupCount'])) {
$result[] = $graph;
} else {
$result = $graph['rowscount'];
}
} else {
$result[$graph['graphid']] = $graph;
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例14: get
//.........这里部分代码省略.........
$result[$item['itemid']]['hosts'][] = $template;
}
}
}
}
// Adding triggers
if (!is_null($options['selectTriggers'])) {
$objParams = array('nodeids' => $nodeids, 'itemids' => $itemids, 'preservekeys' => true);
if (in_array($options['selectTriggers'], $subselectsAllowedOutputs)) {
$objParams['output'] = $options['selectTriggers'];
$triggers = API::TriggerPrototype()->get($objParams);
if (!is_null($options['limitSelects'])) {
order_result($triggers, 'description');
}
$count = array();
foreach ($triggers as $triggerid => $trigger) {
unset($triggers[$triggerid]['items']);
foreach ($trigger['items'] as $item) {
if (!is_null($options['limitSelects'])) {
if (!isset($count[$item['itemid']])) {
$count[$item['itemid']] = 0;
}
$count[$item['itemid']]++;
if ($count[$item['itemid']] > $options['limitSelects']) {
continue;
}
}
$result[$item['itemid']]['triggers'][] =& $triggers[$triggerid];
}
}
} elseif (API_OUTPUT_COUNT == $options['selectTriggers']) {
$objParams['countOutput'] = 1;
$objParams['groupCount'] = 1;
$triggers = API::TriggerPrototype()->get($objParams);
$triggers = zbx_toHash($triggers, 'parent_itemid');
foreach ($result as $itemid => $item) {
if (isset($triggers[$itemid])) {
$result[$itemid]['triggers'] = $triggers[$itemid]['rowscount'];
} else {
$result[$itemid]['triggers'] = 0;
}
}
}
}
// Adding applications
if (!is_null($options['selectApplications']) && str_in_array($options['selectApplications'], $subselectsAllowedOutputs)) {
$objParams = array('nodeids' => $nodeids, 'output' => $options['selectApplications'], 'itemids' => $itemids, 'preservekeys' => 1);
$applications = API::Application()->get($objParams);
foreach ($applications as $applicationid => $application) {
$aitems = $application['items'];
unset($application['items']);
foreach ($aitems as $inum => $item) {
$result[$item['itemid']]['applications'][] = $application;
}
}
}
// Adding graphs
if (!is_null($options['selectGraphs'])) {
$objParams = array('nodeids' => $nodeids, 'itemids' => $itemids, 'preservekeys' => true);
if (in_array($options['selectGraphs'], $subselectsAllowedOutputs)) {
$objParams['output'] = $options['selectGraphs'];
$graphs = API::GraphPrototype()->get($objParams);
if (!is_null($options['limitSelects'])) {
order_result($graphs, 'name');
}
$count = array();
foreach ($graphs as $graphid => $graph) {
unset($graphs[$graphid]['items']);
foreach ($graph['items'] as $item) {
if (!is_null($options['limitSelects'])) {
if (!isset($count[$item['itemid']])) {
$count[$item['itemid']] = 0;
}
$count[$item['itemid']]++;
if ($count[$item['itemid']] > $options['limitSelects']) {
continue;
}
}
$result[$item['itemid']]['graphs'][] =& $graphs[$graphid];
}
}
} elseif (API_OUTPUT_COUNT == $options['selectGraphs']) {
$objParams['countOutput'] = 1;
$objParams['groupCount'] = 1;
$graphs = API::GraphPrototype()->get($objParams);
$graphs = zbx_toHash($graphs, 'parent_itemid');
foreach ($result as $itemid => $item) {
if (isset($graphs[$itemid])) {
$result[$itemid]['graphs'] = $graphs[$itemid]['rowscount'];
} else {
$result[$itemid]['graphs'] = 0;
}
}
}
}
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}
示例15: get
//.........这里部分代码省略.........
$userGroups = getUserGroupsByUserId($userid);
$sqlParts['where'][] = 'EXISTS (' . 'SELECT NULL' . ' FROM hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE hm.hostid=hgg.hostid' . ' GROUP BY hgg.hostid' . ' HAVING MIN(r.permission)>' . PERM_DENY . ' AND MAX(r.permission)>=' . zbx_dbstr($permission) . ')';
}
}
// global macro
if (!is_null($options['globalmacro'])) {
$options['groupids'] = null;
$options['hostmacroids'] = null;
$options['triggerids'] = null;
$options['hostids'] = null;
$options['itemids'] = null;
$options['selectGroups'] = null;
$options['selectTemplates'] = null;
$options['selectHosts'] = null;
}
// globalmacroids
if (!is_null($options['globalmacroids'])) {
zbx_value2array($options['globalmacroids']);
$sqlPartsGlobal['where'][] = dbConditionInt('gm.globalmacroid', $options['globalmacroids']);
}
// hostmacroids
if (!is_null($options['hostmacroids'])) {
zbx_value2array($options['hostmacroids']);
$sqlParts['where'][] = dbConditionInt('hm.hostmacroid', $options['hostmacroids']);
}
// groupids
if (!is_null($options['groupids'])) {
zbx_value2array($options['groupids']);
$sqlParts['from']['hosts_groups'] = 'hosts_groups hg';
$sqlParts['where'][] = dbConditionInt('hg.groupid', $options['groupids']);
$sqlParts['where']['hgh'] = 'hg.hostid=hm.hostid';
}
// hostids
if (!is_null($options['hostids'])) {
zbx_value2array($options['hostids']);
$sqlParts['where'][] = dbConditionInt('hm.hostid', $options['hostids']);
}
// templateids
if (!is_null($options['templateids'])) {
zbx_value2array($options['templateids']);
$sqlParts['from']['macros_templates'] = 'hosts_templates ht';
$sqlParts['where'][] = dbConditionInt('ht.templateid', $options['templateids']);
$sqlParts['where']['hht'] = 'hm.hostid=ht.hostid';
}
// search
if (is_array($options['search'])) {
zbx_db_search('hostmacro hm', $options, $sqlParts);
zbx_db_search('globalmacro gm', $options, $sqlPartsGlobal);
}
// filter
if (is_array($options['filter'])) {
if (isset($options['filter']['macro'])) {
zbx_value2array($options['filter']['macro']);
$sqlParts['where'][] = dbConditionString('hm.macro', $options['filter']['macro']);
$sqlPartsGlobal['where'][] = dbConditionString('gm.macro', $options['filter']['macro']);
}
}
// sorting
$sqlParts = $this->applyQuerySortOptions('hostmacro', 'hm', $options, $sqlParts);
$sqlPartsGlobal = $this->applyQuerySortOptions('globalmacro', 'gm', $options, $sqlPartsGlobal);
// limit
if (zbx_ctype_digit($options['limit']) && $options['limit']) {
$sqlParts['limit'] = $options['limit'];
$sqlPartsGlobal['limit'] = $options['limit'];
}
// init GLOBALS
if (!is_null($options['globalmacro'])) {
$sqlPartsGlobal = $this->applyQueryOutputOptions('globalmacro', 'gm', $options, $sqlPartsGlobal);
$res = DBselect($this->createSelectQueryFromParts($sqlPartsGlobal), $sqlPartsGlobal['limit']);
while ($macro = DBfetch($res)) {
if ($options['countOutput']) {
$result = $macro['rowscount'];
} else {
$result[$macro['globalmacroid']] = $macro;
}
}
} else {
$sqlParts = $this->applyQueryOutputOptions('hostmacro', 'hm', $options, $sqlParts);
$res = DBselect($this->createSelectQueryFromParts($sqlParts), $sqlParts['limit']);
while ($macro = DBfetch($res)) {
if ($options['countOutput']) {
$result = $macro['rowscount'];
} else {
$result[$macro['hostmacroid']] = $macro;
}
}
}
if (!is_null($options['countOutput'])) {
return $result;
}
if ($result) {
$result = $this->addRelatedObjects($options, $result);
$result = $this->unsetExtraFields($result, array('hostid'), $options['output']);
}
// removing keys (hash -> array)
if (is_null($options['preservekeys'])) {
$result = zbx_cleanHashes($result);
}
return $result;
}