summaryrefslogtreecommitdiff
path: root/vendor/doctrine/orm/src/NativeQuery.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/orm/src/NativeQuery.php')
-rw-r--r--vendor/doctrine/orm/src/NativeQuery.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/NativeQuery.php b/vendor/doctrine/orm/src/NativeQuery.php
new file mode 100644
index 0000000..6cee0e8
--- /dev/null
+++ b/vendor/doctrine/orm/src/NativeQuery.php
@@ -0,0 +1,68 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Doctrine\ORM;
6
7use Doctrine\DBAL\Result;
8use Doctrine\ORM\Query\ParameterTypeInferer;
9
10use function array_values;
11use function is_int;
12use function key;
13use function ksort;
14
15/**
16 * Represents a native SQL query.
17 *
18 * @final
19 */
20class NativeQuery extends AbstractQuery
21{
22 private string $sql;
23
24 /** @return $this */
25 public function setSQL(string $sql): self
26 {
27 $this->sql = $sql;
28
29 return $this;
30 }
31
32 public function getSQL(): string
33 {
34 return $this->sql;
35 }
36
37 protected function _doExecute(): Result|int
38 {
39 $parameters = [];
40 $types = [];
41
42 foreach ($this->getParameters() as $parameter) {
43 $name = $parameter->getName();
44 $value = $this->processParameterValue($parameter->getValue());
45 $type = $parameter->getValue() === $value
46 ? $parameter->getType()
47 : ParameterTypeInferer::inferType($value);
48
49 $parameters[$name] = $value;
50 $types[$name] = $type;
51 }
52
53 if ($parameters && is_int(key($parameters))) {
54 ksort($parameters);
55 ksort($types);
56
57 $parameters = array_values($parameters);
58 $types = array_values($types);
59 }
60
61 return $this->em->getConnection()->executeQuery(
62 $this->sql,
63 $parameters,
64 $types,
65 $this->queryCacheProfile,
66 );
67 }
68}