From eba8fec1fb6460937504fe4dcd6036b5ce1a4a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sat, 22 Jul 2017 22:39:47 +0200 Subject: [PATCH] Move identifier types extraction to a method --- .../Entity/BasicEntityPersister.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 9cec30ffd..972199c5e 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -344,16 +344,28 @@ class BasicEntityPersister implements EntityPersister . ' FROM ' . $tableName . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?'; + + $flatId = $this->identifierFlattener->flattenIdentifier($versionedClass, $id); + + $value = $this->conn->fetchColumn( + $sql, + array_values($flatId), + 0, + $this->extractIdentifierTypes($id, $versionedClass) + ); + + return Type::getType($fieldMapping['type'])->convertToPHPValue($value, $this->platform); + } + + private function extractIdentifierTypes(array $id, ClassMetadata $versionedClass) : array + { $types = []; + foreach ($id as $field => $value) { $types = array_merge($types, $this->getTypes($field, $value, $versionedClass)); } - $flatId = $this->identifierFlattener->flattenIdentifier($versionedClass, $id); - - $value = $this->conn->fetchColumn($sql, array_values($flatId), 0, $types); - - return Type::getType($fieldMapping['type'])->convertToPHPValue($value, $this->platform); + return $types; } /**