Source
$dservices = $this->unsetExtraFields($dservices, ['dserviceid', 'dhostid'], $options['selectDServices']);
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Class containing methods for operations with discovery hosts.
*/
class CDHost extends CApiService {
public const ACCESS_RULES = [
'get' => ['min_user_type' => USER_TYPE_ZABBIX_USER]
];
protected $tableName = 'dhosts';
protected $tableAlias = 'dh';
protected $sortColumns = ['dhostid', 'druleid'];
public const OUTPUT_FIELDS = ['dhostid', 'druleid', 'status', 'lastup', 'lastdown'];
/**
* Get host data.
*
* @param array $options
* @param array $options['groupids'] HostGroup IDs
* @param bool $options['monitored_hosts'] only monitored Hosts
* @param bool $options['templated_hosts'] include templates in result
* @param bool $options['with_items'] only with items
* @param bool $options['with_triggers'] only with triggers
* @param bool $options['with_httptests'] only with http tests
* @param bool $options['with_graphs'] only with graphs
* @param bool $options['editable'] only with read-write permission. Ignored for SuperAdmins
* @param bool $options['selectTemplates'] select Templates
* @param bool $options['selectItems'] select Items
* @param bool $options['selectTriggers'] select Triggers
* @param bool $options['selectGraphs'] select Graphs
* @param int $options['count'] count Hosts, returned column name is rowscount
* @param string $options['pattern'] search hosts by pattern in Host name
* @param string $options['extendPattern'] search hosts by pattern in Host name, ip and DNS
* @param int $options['limit'] limit selection
* @param string $options['sortfield'] field to sort by
* @param string $options['sortorder'] sort order
*
* @return array Host data as array or false if error
*/
public function get($options = []) {
$result = [];
$sqlParts = [
'select' => ['dhosts' => 'dh.dhostid'],
'from' => ['dhosts' => 'dhosts dh'],
'where' => [],