1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Yiisoft\Db\Pgsql; |
6
|
|
|
|
7
|
|
|
use Exception; |
8
|
|
|
use Throwable; |
9
|
|
|
use Yiisoft\Db\Driver\PDO\AbstractCommandPDO; |
10
|
|
|
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface; |
11
|
|
|
use Yiisoft\Db\Exception\ConvertException; |
12
|
|
|
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface; |
13
|
|
|
|
14
|
|
|
use function is_array; |
15
|
|
|
|
16
|
|
|
final class CommandPDO extends AbstractCommandPDO |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @inheritDoc |
20
|
|
|
*/ |
21
|
2 |
|
public function insertWithReturningPks(string $table, array $columns): bool|array |
22
|
|
|
{ |
23
|
2 |
|
$params = []; |
24
|
2 |
|
$sql = $this->queryBuilder()->insertWithReturningPks($table, $columns, $params); |
|
|
|
|
25
|
|
|
|
26
|
2 |
|
$this->setSql($sql)->bindValues($params); |
27
|
2 |
|
$this->prepare(false); |
28
|
|
|
|
29
|
|
|
/** @var mixed $queryOne */ |
30
|
2 |
|
$queryOne = $this->queryOne(); |
31
|
|
|
|
32
|
2 |
|
return is_array($queryOne) ? $queryOne : false; |
33
|
|
|
} |
34
|
|
|
|
35
|
267 |
|
public function queryBuilder(): QueryBuilderInterface |
36
|
|
|
{ |
37
|
267 |
|
return $this->db->getQueryBuilder(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @psalm-suppress UnusedClosureParam |
42
|
|
|
* |
43
|
|
|
* @throws \Yiisoft\Db\Exception\Exception |
44
|
|
|
* @throws Throwable |
45
|
|
|
*/ |
46
|
244 |
|
protected function internalExecute(string|null $rawSql): void |
47
|
|
|
{ |
48
|
244 |
|
$attempt = 0; |
49
|
|
|
|
50
|
244 |
|
while (true) { |
51
|
|
|
try { |
52
|
|
|
if ( |
53
|
244 |
|
++$attempt === 1 |
54
|
244 |
|
&& $this->isolationLevel !== null |
55
|
244 |
|
&& $this->db->getTransaction() === null |
56
|
|
|
) { |
57
|
1 |
|
$this->db->transaction( |
58
|
1 |
|
fn (ConnectionPDOInterface $db) => $this->internalExecute($rawSql), |
|
|
|
|
59
|
1 |
|
$this->isolationLevel |
60
|
1 |
|
); |
61
|
|
|
} else { |
62
|
244 |
|
$this->pdoStatement?->execute(); |
63
|
|
|
} |
64
|
244 |
|
break; |
65
|
8 |
|
} catch (Exception $e) { |
66
|
8 |
|
$rawSql = $rawSql ?: $this->getRawSql(); |
67
|
8 |
|
$e = (new ConvertException($e, $rawSql))->run(); |
68
|
|
|
|
69
|
8 |
|
if ($this->retryHandler === null || !($this->retryHandler)($e, $attempt)) { |
70
|
8 |
|
throw $e; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.