1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Mssql\PDO; |
6
|
|
|
|
7
|
|
|
use PDOException; |
8
|
|
|
use Yiisoft\Db\Command\CommandPDO; |
9
|
|
|
use Yiisoft\Db\Exception\ConvertException; |
10
|
|
|
use Yiisoft\Db\Query\QueryBuilderInterface; |
|
|
|
|
11
|
|
|
|
12
|
|
|
use function is_array; |
13
|
|
|
|
14
|
|
|
final class CommandPDOMssql extends CommandPDO |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @inheritDoc |
18
|
|
|
*/ |
19
|
2 |
|
public function insertEx(string $table, array $columns): bool|array |
20
|
|
|
{ |
21
|
2 |
|
$params = []; |
22
|
2 |
|
$sql = $this->queryBuilder()->insertEx($table, $columns, $params); |
23
|
|
|
|
24
|
2 |
|
$this->setSql($sql)->bindValues($params); |
25
|
2 |
|
$this->prepare(false); |
26
|
|
|
|
27
|
|
|
/** @psalm-var array|bool */ |
28
|
2 |
|
$result = $this->queryOne(); |
29
|
|
|
|
30
|
2 |
|
return is_array($result) ? $result : false; |
31
|
|
|
} |
32
|
|
|
|
33
|
214 |
|
public function queryBuilder(): QueryBuilderInterface |
34
|
|
|
{ |
35
|
214 |
|
return $this->db->getQueryBuilder(); |
36
|
|
|
} |
37
|
|
|
|
38
|
194 |
|
protected function getCacheKey(int $queryMode, string $rawSql): array |
39
|
|
|
{ |
40
|
|
|
return [ |
41
|
194 |
|
__CLASS__, |
42
|
|
|
$queryMode, |
43
|
194 |
|
$this->db->getDriver()->getDsn(), |
44
|
194 |
|
$this->db->getDriver()->getUsername(), |
45
|
|
|
$rawSql, |
46
|
|
|
]; |
47
|
|
|
} |
48
|
|
|
|
49
|
203 |
|
protected function internalExecute(?string $rawSql): void |
50
|
|
|
{ |
51
|
203 |
|
$attempt = 0; |
52
|
|
|
|
53
|
203 |
|
while (true) { |
54
|
|
|
try { |
55
|
|
|
if ( |
56
|
203 |
|
++$attempt === 1 |
57
|
203 |
|
&& $this->isolationLevel !== null |
58
|
203 |
|
&& $this->db->getTransaction() === null |
59
|
|
|
) { |
60
|
|
|
$this->db->transaction( |
61
|
|
|
fn (string $rawSql) => $this->internalExecute($rawSql), |
62
|
|
|
$this->isolationLevel |
63
|
|
|
); |
64
|
|
|
} else { |
65
|
203 |
|
$this->pdoStatement?->execute(); |
66
|
|
|
} |
67
|
202 |
|
break; |
68
|
5 |
|
} catch (PDOException $e) { |
69
|
5 |
|
$rawSql = $rawSql ?: $this->getRawSql(); |
70
|
5 |
|
$e = (new ConvertException($e, $rawSql))->run(); |
71
|
|
|
|
72
|
5 |
|
if ($this->retryHandler === null || !($this->retryHandler)($e, $attempt)) { |
73
|
5 |
|
throw $e; |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|
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