/
ServicegroupQuery.php
49 lines (44 loc) · 1.61 KB
/
ServicegroupQuery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
class ServicegroupQuery extends IdoQuery
{
protected $columnMap = array(
'servicegroups' => array(
'servicegroup_name' => 'sgo.name1 COLLATE latin1_general_ci',
'servicegroup_alias' => 'sg.alias',
),
'services' => array(
'host' => 'so.name1 COLLATE latin1_general_ci',
'host_name' => 'so.name1',
'service' => 'so.name2 COLLATE latin1_general_ci',
'service_host_name' => 'so.name1 COLLATE latin1_general_ci',
'service_description' => 'so.name2 COLLATE latin1_general_ci'
)
);
protected function joinBaseTables()
{
$this->select->from(
array('sg' => $this->prefix . 'servicegroups'),
array()
)->join(
array('sgo' => $this->prefix . 'objects'),
'sg.servicegroup_object_id = sgo.' . $this->object_id
. ' AND sgo.is_active = 1',
array()
);
$this->joinedVirtualTables = array('servicegroups' => true);
}
protected function joinServices()
{
$this->select->join(
array('sgm' => $this->prefix . 'servicegroup_members'),
'sgm.' . $this->servicegroup_id . ' = sg.' . $this->servicegroup_id,
array()
)->join(
array('so' => $this->prefix . 'objects'),
'sgm.service_object_id = so.' . $this->object_id . ' AND so.is_active = 1',
array()
);
}
}