diff options
| author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
| commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
| tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/orm/src/NativeQuery.php | |
| parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
| download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.gz AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.tar.bz2 AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip | |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/orm/src/NativeQuery.php')
| -rw-r--r-- | vendor/doctrine/orm/src/NativeQuery.php | 68 |
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 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\ORM; | ||
| 6 | |||
| 7 | use Doctrine\DBAL\Result; | ||
| 8 | use Doctrine\ORM\Query\ParameterTypeInferer; | ||
| 9 | |||
| 10 | use function array_values; | ||
| 11 | use function is_int; | ||
| 12 | use function key; | ||
| 13 | use function ksort; | ||
| 14 | |||
| 15 | /** | ||
| 16 | * Represents a native SQL query. | ||
| 17 | * | ||
| 18 | * @final | ||
| 19 | */ | ||
| 20 | class 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 | } | ||
