1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | namespace Edyan\Neuralyzer\Service; |
||||
6 | |||||
7 | use Edyan\Neuralyzer\Exception\NeuralyzerException; |
||||
8 | use Edyan\Neuralyzer\Utils\DBUtils; |
||||
9 | |||||
10 | /** |
||||
11 | * Class Database to inject in expression language |
||||
12 | */ |
||||
13 | class Database implements ServiceInterface |
||||
14 | { |
||||
15 | /** |
||||
16 | * @var DBUtils |
||||
17 | */ |
||||
18 | private $dbUtils; |
||||
19 | |||||
20 | /** |
||||
21 | * Used for auto wiring |
||||
22 | */ |
||||
23 | 53 | public function __construct(DBUtils $dbUtils) |
|||
24 | { |
||||
25 | 53 | $this->dbUtils = $dbUtils; |
|||
26 | 53 | } |
|||
27 | |||||
28 | /** |
||||
29 | * Returns service's name |
||||
30 | */ |
||||
31 | public function getName(): string |
||||
32 | { |
||||
33 | 51 | return 'db'; |
|||
34 | } |
||||
35 | 51 | ||||
36 | /** |
||||
37 | * @throws NeuralyzerException |
||||
38 | * |
||||
39 | * @return array |
||||
40 | */ |
||||
41 | public function query(string $sql): ?array |
||||
42 | { |
||||
43 | $conn = $this->dbUtils->getConn(); |
||||
44 | $sql = trim($sql); |
||||
45 | 7 | try { |
|||
46 | $res = $conn->query($sql); |
||||
0 ignored issues
–
show
|
|||||
47 | 7 | if (strpos($sql, 'SELECT') === 0) { |
|||
48 | 7 | return $res->fetchAll(); |
|||
0 ignored issues
–
show
The function
Doctrine\DBAL\Driver\ResultStatement::fetchAll() has been deprecated: Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. ![]() |
|||||
49 | } |
||||
50 | 7 | ||||
51 | 5 | return null; |
|||
52 | 2 | } catch (\Exception $e) { |
|||
53 | throw new NeuralyzerException($e->getMessage()); |
||||
54 | } |
||||
55 | 3 | } |
|||
56 | } |
||||
57 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.