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