AskQueryHandler::runQuery()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
3
/**
4
 * This file is part of the sweetrdf/InMemoryStoreSqlite package and licensed under
5
 * the terms of the GPL-2 license.
6
 *
7
 * (c) Konrad Abicht <[email protected]>
8
 * (c) Benjamin Nowack
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace sweetrdf\InMemoryStoreSqlite\Store\QueryHandler;
15
16
class AskQueryHandler extends SelectQueryHandler
17
{
18 3
    public function runQuery($infos)
19
    {
20 3
        $infos['query']['limit'] = 1;
21 3
        $this->infos = $infos;
22 3
        $this->buildResultVars();
23
24 3
        return parent::runQuery($this->infos);
25
    }
26
27 3
    private function buildResultVars()
28
    {
29 3
        $this->infos['query']['result_vars'][] = [
30 3
            'var' => '1',
31 3
            'aggregate' => '',
32 3
            'alias' => 'success',
33 3
        ];
34
    }
35
36 3
    protected function getFinalQueryResult($q_sql, $tmp_tbl)
37
    {
38 3
        $row = $this->store->getDBObject()->fetchRow('SELECT success FROM '.$tmp_tbl);
39 3
        $r = isset($row['success']) ? $row['success'] : 0;
40
41 3
        return $r ? true : false;
42
    }
43
}
44