Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
PdoSqlite
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 search
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3/**
4 * phpMyFAQ SQLite3 (PDO_SQLITE) based search classes.
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package phpMyFAQ
11 *
12 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
13 * @copyright 2025-2026 phpMyFAQ Team
14 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
15 * @link      https://www.phpmyfaq.de
16 * @since     2025-02-12
17 */
18
19declare(strict_types=1);
20
21namespace phpMyFAQ\Search\Database;
22
23use Exception;
24use phpMyFAQ\Search\SearchDatabase;
25
26/**
27 * Class PdoSqlite
28 *
29 * @package phpMyFAQ\Search\Database
30 */
31class PdoSqlite extends SearchDatabase implements DatabaseInterface
32{
33    /**
34     * Prepares the search and executes it.
35     *
36     * @param  string $searchTerm Search ter
37     * @throws Exception
38     */
39    #[\Override]
40    public function search(string $searchTerm): mixed
41    {
42        if (is_numeric($searchTerm) && (bool) $this->configuration->get(item: 'search.searchForSolutionId')) {
43            return parent::search($searchTerm);
44        }
45
46        $query = sprintf(
47            '
48            SELECT
49                %s
50            FROM 
51                %s %s %s
52            WHERE
53                %s
54                %s',
55            $this->getResultColumns(),
56            $this->getTable(),
57            $this->getJoinedTable(),
58            $this->getJoinedColumns(),
59            $this->getMatchClause($searchTerm),
60            $this->getConditions(),
61        );
62
63        $this->resultSet = $this->configuration->getDb()->query($query);
64
65        return $this->resultSet;
66    }
67}