summaryrefslogtreecommitdiffstats
path: root/vendor/gipfl/icingaweb2/src/Table/SimpleQueryBasedTable.php
blob: 8d6015aa719cebfcee4670197a7bc1120cab5d9a (plain)
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
<?php

namespace gipfl\IcingaWeb2\Table;

use Icinga\Data\SimpleQuery;
use gipfl\IcingaWeb2\Data\SimpleQueryPaginationAdapter;

abstract class SimpleQueryBasedTable extends QueryBasedTable
{
    /** @var SimpleQuery */
    private $query;

    protected function getPaginationAdapter()
    {
        return new SimpleQueryPaginationAdapter($this->getQuery());
    }

    protected function fetchQueryRows()
    {
        return $this->query->fetchAll();
    }

    /**
     * @return SimpleQuery
     */
    public function getQuery()
    {
        if ($this->query === null) {
            $this->query = $this->prepareQuery();
        }

        return $this->query;
    }
}