EventHistoryQuery: Rename baseQuery to select

This commit is contained in:
Eric Lippmann 2014-04-15 17:59:55 +02:00
parent 67ce376ef0
commit 30e649eeb4

View File

@ -2,7 +2,7 @@
namespace Icinga\Module\Monitoring\Backend\Ido\Query; namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use \Zend_Db_Select; use Zend_Db_Select;
class EventHistoryQuery extends IdoQuery class EventHistoryQuery extends IdoQuery
{ {
@ -50,7 +50,6 @@ class EventHistoryQuery extends IdoQuery
'attempt', 'attempt',
'max_attempts', 'max_attempts',
); );
$this->subQueries = array( $this->subQueries = array(
$this->createSubQuery('Statehistory', $columns), $this->createSubQuery('Statehistory', $columns),
$this->createSubQuery('Downtimestarthistory', $columns), $this->createSubQuery('Downtimestarthistory', $columns),
@ -60,14 +59,13 @@ class EventHistoryQuery extends IdoQuery
); );
$sub = $this->db->select()->union($this->subQueries, Zend_Db_Select::SQL_UNION_ALL); $sub = $this->db->select()->union($this->subQueries, Zend_Db_Select::SQL_UNION_ALL);
$this->baseQuery = $this->db->select()->from(
$this->select->from(
array('eho' => $this->prefix . 'objects'), array('eho' => $this->prefix . 'objects'),
array() array()
)->join( )->join(
array('eh' => $sub), array('eh' => $sub),
'eho.' . $this->object_id 'eho.' . $this->object_id . ' = eh.' . $this->object_id . ' AND eho.is_active = 1',
. ' = eh.' . $this->object_id
. ' AND eho.is_active = 1',
array() array()
); );
$this->joinedVirtualTables = array('eventhistory' => true); $this->joinedVirtualTables = array('eventhistory' => true);
@ -75,21 +73,19 @@ class EventHistoryQuery extends IdoQuery
protected function joinHostgroups() protected function joinHostgroups()
{ {
$this->baseQuery->join( $this->select->join(
array('hgm' => $this->prefix . 'hostgroup_members'), array('hgm' => $this->prefix . 'hostgroup_members'),
'hgm.host_object_id = eho.object_id', 'hgm.host_object_id = eho.object_id',
array() array()
)->join( )->join(
array('hg' => $this->prefix . 'hostgroups'), array('hg' => $this->prefix . 'hostgroups'),
"hgm.hostgroup_id = hg.$this->hostgroup_id", 'hgm.hostgroup_id = hg.' . $this->hostgroup_id,
array() array()
)->join( )->join(
array('hgo' => $this->prefix . 'objects'), array('hgo' => $this->prefix . 'objects'),
'hgo.' . $this->object_id. ' = hg.hostgroup_object_id' 'hgo.' . $this->object_id. ' = hg.hostgroup_object_id' . ' AND hgo.is_active = 1',
. ' AND hgo.is_active = 1',
array() array()
); );
return $this; return $this;
} }