Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Sqlite3
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 search
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3/**
4 * phpMyFAQ 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 2012-2026 phpMyFAQ Team
14 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
15 *
16 * @link  https://www.phpmyfaq.de
17 * @since 2012-12-26
18 */
19
20declare(strict_types=1);
21
22namespace phpMyFAQ\Search\Database;
23
24use Exception;
25use Override;
26use phpMyFAQ\Search\SearchDatabase;
27
28/**
29 * Class Sqlite3
30 *
31 * @package phpMyFAQ\Search\Database
32 * @deprecated Use PDO instead. Will be removed in the v5.0 release.
33 */
34class Sqlite3 extends SearchDatabase implements DatabaseInterface
35{
36    /**
37     * Prepares the search and executes it.
38     *
39     * @param  string $searchTerm Search ter
40     * @throws Exception
41     */
42    #[Override]
43    public function search(string $searchTerm): mixed
44    {
45        if (is_numeric($searchTerm) && (bool) $this->configuration->get(item: 'search.searchForSolutionId')) {
46            parent::search($searchTerm);
47
48            return $this->resultSet;
49        }
50
51        $query = sprintf(
52            '
53                SELECT
54                    %s
55                FROM 
56                    %s %s %s
57                WHERE
58                    %s
59                    %s',
60            $this->getResultColumns(),
61            $this->getTable(),
62            $this->getJoinedTable(),
63            $this->getJoinedColumns(),
64            $this->getMatchClause($searchTerm),
65            $this->getConditions(),
66        );
67
68        $this->resultSet = $this->configuration->getDb()->query($query);
69
70        return $this->resultSet;
71    }
72}