1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Rougin\Windstorm\Doctrine; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManager; |
|
|
|
|
6
|
|
|
use Doctrine\ORM\NativeQuery; |
|
|
|
|
7
|
|
|
use Doctrine\ORM\Query\ResultSetMapping; |
|
|
|
|
8
|
|
|
use Rougin\Windstorm\ResultInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Result |
12
|
|
|
* |
13
|
|
|
* @package Windstorm |
14
|
|
|
* @author Rougin Gutib <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class Result implements ResultInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var \Doctrine\ORM\EntityManager |
20
|
|
|
*/ |
21
|
|
|
protected $manager; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var \Doctrine\ORM\Query\ResultSetMapping |
25
|
|
|
*/ |
26
|
|
|
protected $mapping; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Initializes the entity manager instance. |
30
|
|
|
* |
31
|
|
|
* @param \Doctrine\ORM\EntityManager $manager |
32
|
|
|
*/ |
33
|
|
|
public function __construct(EntityManager $manager) |
34
|
|
|
{ |
35
|
|
|
$this->manager = $manager; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Returns the entity manager instance. |
40
|
|
|
* |
41
|
|
|
* @return \Doctrine\ORM\EntityManager |
42
|
|
|
*/ |
43
|
|
|
public function manager() |
44
|
|
|
{ |
45
|
|
|
return $this->manager; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Executes an SQL statement with its bindings and types. |
50
|
|
|
* |
51
|
|
|
* @param string $sql |
52
|
|
|
* @param array $bindings |
53
|
|
|
* @param array $types |
54
|
|
|
* @return mixed |
55
|
|
|
*/ |
56
|
|
|
public function execute($sql, array $parameters, array $types) |
57
|
|
|
{ |
58
|
|
|
$connection = $this->manager->getConnection(); |
59
|
|
|
|
60
|
|
|
if (strpos($sql, 'SELECT') === false) |
61
|
|
|
{ |
62
|
|
|
return $connection->executeUpdate($sql, $parameters, $types); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$query = new NativeQuery($this->manager); |
66
|
|
|
|
67
|
|
|
$query->setSql($sql)->setResultSetMapping($this->mapping); |
68
|
|
|
|
69
|
|
|
return (array) $query->getResult(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Sets the result set mapping instance. |
74
|
|
|
* |
75
|
|
|
* @param \Doctrine\ORM\Query\ResultSetMapping $mapping |
76
|
|
|
* @return self |
77
|
|
|
*/ |
78
|
|
|
public function mapping(ResultSetMapping $mapping) |
79
|
|
|
{ |
80
|
|
|
$this->mapping = $mapping; |
81
|
|
|
|
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths