1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Doctrine\ORM\Query; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Types\Type; |
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
9
|
|
|
use Doctrine\ORM\Mapping\AssociationMetadata; |
10
|
|
|
use Doctrine\ORM\Mapping\ClassMetadata; |
11
|
|
|
use Doctrine\ORM\Mapping\FieldMetadata; |
12
|
|
|
use Doctrine\ORM\Mapping\InheritanceType; |
13
|
|
|
use Doctrine\ORM\Mapping\JoinColumnMetadata; |
14
|
|
|
use Doctrine\ORM\Mapping\MappingException; |
15
|
|
|
use Doctrine\ORM\Mapping\ToOneAssociationMetadata; |
16
|
|
|
use Doctrine\ORM\Utility\PersisterHelper; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* A ResultSetMappingBuilder uses the EntityManager to automatically populate entity fields. |
20
|
|
|
* |
21
|
|
|
* @author Michael Ridgway <[email protected]> |
22
|
|
|
* @since 2.1 |
23
|
|
|
*/ |
24
|
|
|
class ResultSetMappingBuilder extends ResultSetMapping |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Picking this rename mode will register entity columns as is, |
28
|
|
|
* as they are in the database. This can cause clashes when multiple |
29
|
|
|
* entities are fetched that have columns with the same name. |
30
|
|
|
* |
31
|
|
|
* @var int |
32
|
|
|
*/ |
33
|
|
|
const COLUMN_RENAMING_NONE = 1; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Picking custom renaming allows the user to define the renaming |
37
|
|
|
* of specific columns with a rename array that contains column names as |
38
|
|
|
* keys and result alias as values. |
39
|
|
|
* |
40
|
|
|
* @var int |
41
|
|
|
*/ |
42
|
|
|
const COLUMN_RENAMING_CUSTOM = 2; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Incremental renaming uses a result set mapping internal counter to add a |
46
|
|
|
* number to each column result, leading to uniqueness. This only works if |
47
|
|
|
* you use {@see generateSelectClause()} to generate the SELECT clause for |
48
|
|
|
* you. |
49
|
|
|
* |
50
|
|
|
* @var int |
51
|
|
|
*/ |
52
|
|
|
const COLUMN_RENAMING_INCREMENT = 3; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var int |
56
|
|
|
*/ |
57
|
|
|
private $sqlCounter = 0; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var EntityManagerInterface |
61
|
|
|
*/ |
62
|
|
|
private $em; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Default column renaming mode. |
66
|
|
|
* |
67
|
|
|
* @var int |
68
|
|
|
*/ |
69
|
|
|
private $defaultRenameMode; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param EntityManagerInterface $em |
73
|
|
|
* @param integer $defaultRenameMode |
74
|
|
|
*/ |
75
|
22 |
|
public function __construct(EntityManagerInterface $em, $defaultRenameMode = self::COLUMN_RENAMING_NONE) |
76
|
|
|
{ |
77
|
22 |
|
$this->em = $em; |
78
|
22 |
|
$this->defaultRenameMode = $defaultRenameMode; |
79
|
22 |
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Adds a root entity and all of its fields to the result set. |
83
|
|
|
* |
84
|
|
|
* @param string $class The class name of the root entity. |
85
|
|
|
* @param string $alias The unique alias to use for the root entity. |
86
|
|
|
* @param array $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). |
87
|
|
|
* @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). |
88
|
|
|
* |
89
|
|
|
* @return void |
90
|
|
|
*/ |
91
|
16 |
|
public function addRootEntityFromClassMetadata( |
92
|
|
|
string $class, |
93
|
|
|
string $alias, |
94
|
|
|
array $renamedColumns = [], |
95
|
|
|
int $renameMode = null |
96
|
|
|
) |
97
|
|
|
{ |
98
|
16 |
|
$renameMode = $renameMode ?: (empty($renamedColumns) ? $this->defaultRenameMode : self::COLUMN_RENAMING_CUSTOM); |
99
|
|
|
|
100
|
16 |
|
$this->addEntityResult($class, $alias); |
101
|
16 |
|
$this->addAllClassFields($class, $alias, $renamedColumns, $renameMode); |
102
|
15 |
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Adds a joined entity and all of its fields to the result set. |
106
|
|
|
* |
107
|
|
|
* @param string $class The class name of the joined entity. |
108
|
|
|
* @param string $alias The unique alias to use for the joined entity. |
109
|
|
|
* @param string $parentAlias The alias of the entity result that is the parent of this joined result. |
110
|
|
|
* @param string $relation The association field that connects the parent entity result |
111
|
|
|
* with the joined entity result. |
112
|
|
|
* @param array $renamedColumns Columns that have been renamed (tableColumnName => queryColumnName). |
113
|
|
|
* @param int|null $renameMode One of the COLUMN_RENAMING_* constants or array for BC reasons (CUSTOM). |
114
|
|
|
* |
115
|
|
|
* @return void |
116
|
|
|
*/ |
117
|
3 |
|
public function addJoinedEntityFromClassMetadata( |
118
|
|
|
string $class, |
119
|
|
|
string $alias, |
120
|
|
|
string $parentAlias, |
121
|
|
|
string $relation, |
122
|
|
|
array $renamedColumns = [], |
123
|
|
|
int $renameMode = null |
124
|
|
|
) |
125
|
|
|
{ |
126
|
3 |
|
$renameMode = $renameMode ?: (empty($renamedColumns) ? $this->defaultRenameMode : self::COLUMN_RENAMING_CUSTOM); |
127
|
|
|
|
128
|
3 |
|
$this->addJoinedEntityResult($class, $alias, $parentAlias, $relation); |
129
|
3 |
|
$this->addAllClassFields($class, $alias, $renamedColumns, $renameMode); |
130
|
2 |
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Adds all fields of the given class to the result set mapping (columns and meta fields). |
134
|
|
|
* |
135
|
|
|
* @param string $class |
136
|
|
|
* @param string $alias |
137
|
|
|
* @param array $customRenameColumns |
138
|
|
|
* |
139
|
|
|
* @return void |
140
|
|
|
* |
141
|
|
|
* @throws \InvalidArgumentException |
142
|
|
|
*/ |
143
|
16 |
|
protected function addAllClassFields(string $class, string $alias, array $customRenameColumns, int $renameMode) : void |
144
|
|
|
{ |
145
|
|
|
/** @var ClassMetadata $classMetadata */ |
146
|
16 |
|
$classMetadata = $this->em->getClassMetadata($class); |
147
|
16 |
|
$platform = $this->em->getConnection()->getDatabasePlatform(); |
148
|
|
|
|
149
|
16 |
|
if (! $this->isInheritanceSupported($classMetadata)) { |
150
|
1 |
|
throw new \InvalidArgumentException( |
151
|
1 |
|
'ResultSetMapping builder does not currently support your inheritance scheme.' |
152
|
|
|
); |
153
|
|
|
} |
154
|
|
|
|
155
|
15 |
|
foreach ($classMetadata->getDeclaredPropertiesIterator() as $property) { |
156
|
|
|
switch (true) { |
157
|
15 |
|
case ($property instanceof FieldMetadata): |
158
|
15 |
|
$columnName = $property->getColumnName(); |
159
|
15 |
|
$columnAlias = $platform->getSQLResultCasing( |
160
|
15 |
|
$this->getColumnAlias($columnName, $renameMode, $customRenameColumns) |
161
|
|
|
); |
162
|
|
|
|
163
|
15 |
|
if (isset($this->fieldMappings[$columnAlias])) { |
164
|
1 |
|
throw new \InvalidArgumentException( |
165
|
1 |
|
sprintf("The column '%s' conflicts with another column in the mapper.", $columnName) |
166
|
|
|
); |
167
|
|
|
} |
168
|
|
|
|
169
|
15 |
|
$this->addFieldResult($alias, $columnAlias, $property->getName()); |
170
|
15 |
|
break; |
171
|
|
|
|
172
|
10 |
|
case ($property instanceof ToOneAssociationMetadata && $property->isOwningSide()): |
173
|
10 |
|
$targetClass = $this->em->getClassMetadata($property->getTargetEntity()); |
|
|
|
|
174
|
|
|
|
175
|
10 |
|
foreach ($property->getJoinColumns() as $joinColumn) { |
|
|
|
|
176
|
|
|
/** @var JoinColumnMetadata $joinColumn */ |
177
|
10 |
|
$columnName = $joinColumn->getColumnName(); |
178
|
10 |
|
$referencedColumnName = $joinColumn->getReferencedColumnName(); |
179
|
10 |
|
$columnAlias = $platform->getSQLResultCasing( |
180
|
10 |
|
$this->getColumnAlias($columnName, $renameMode, $customRenameColumns) |
181
|
|
|
); |
182
|
|
|
|
183
|
10 |
|
if (isset($this->metaMappings[$columnAlias])) { |
184
|
|
|
throw new \InvalidArgumentException( |
185
|
|
|
sprintf("The column '%s' conflicts with another column in the mapper.", $columnName) |
186
|
|
|
); |
187
|
|
|
} |
188
|
|
|
|
189
|
10 |
|
if (! $joinColumn->getType()) { |
190
|
4 |
|
$joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $targetClass, $this->em)); |
|
|
|
|
191
|
|
|
} |
192
|
|
|
|
193
|
10 |
|
$this->addMetaResult($alias, $columnAlias, $columnName, $property->isPrimaryKey(), $joinColumn->getType()); |
194
|
|
|
} |
195
|
15 |
|
break; |
196
|
|
|
} |
197
|
|
|
} |
198
|
15 |
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Checks if inheritance if supported. |
202
|
|
|
* |
203
|
|
|
* @param ClassMetadata $metadata |
204
|
|
|
* |
205
|
|
|
* @return boolean |
206
|
|
|
*/ |
207
|
16 |
|
private function isInheritanceSupported(ClassMetadata $metadata) |
208
|
|
|
{ |
209
|
16 |
|
if ($metadata->inheritanceType === InheritanceType::SINGLE_TABLE |
210
|
16 |
|
&& in_array($metadata->getClassName(), $metadata->discriminatorMap, true)) { |
211
|
2 |
|
return true; |
212
|
|
|
} |
213
|
|
|
|
214
|
15 |
|
return ! in_array($metadata->inheritanceType, [InheritanceType::SINGLE_TABLE, InheritanceType::JOINED]); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
/** |
218
|
|
|
* Gets column alias for a given column. |
219
|
|
|
* |
220
|
|
|
* @param string $columnName |
221
|
|
|
* @param int $mode |
222
|
|
|
* @param array $customRenameColumns |
223
|
|
|
* |
224
|
|
|
* @return string |
225
|
|
|
*/ |
226
|
15 |
|
private function getColumnAlias($columnName, $mode, array $customRenameColumns) |
227
|
|
|
{ |
228
|
|
|
switch ($mode) { |
229
|
15 |
|
case self::COLUMN_RENAMING_INCREMENT: |
230
|
2 |
|
return $columnName . $this->sqlCounter++; |
231
|
|
|
|
232
|
13 |
|
case self::COLUMN_RENAMING_CUSTOM: |
233
|
3 |
|
return $customRenameColumns[$columnName] ?? $columnName; |
234
|
|
|
|
235
|
12 |
|
case self::COLUMN_RENAMING_NONE: |
|
|
|
|
236
|
12 |
|
return $columnName; |
237
|
|
|
|
238
|
|
|
} |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Adds the mappings of the results of native SQL queries to the result set. |
243
|
|
|
* |
244
|
|
|
* @param ClassMetadata $class |
245
|
|
|
* @param array $queryMapping |
246
|
|
|
* |
247
|
|
|
* @return ResultSetMappingBuilder |
248
|
|
|
*/ |
249
|
3 |
|
public function addNamedNativeQueryMapping(ClassMetadata $class, array $queryMapping) |
250
|
|
|
{ |
251
|
3 |
|
if (isset($queryMapping['resultClass'])) { |
252
|
1 |
|
$entityClass = ($queryMapping['resultClass'] === '__CLASS__') |
253
|
1 |
|
? $class |
254
|
1 |
|
: $this->em->getClassMetadata($queryMapping['resultClass']) |
255
|
|
|
; |
256
|
|
|
|
257
|
1 |
|
$this->addEntityResult($entityClass->getClassName(), 'e0'); |
|
|
|
|
258
|
1 |
|
$this->addNamedNativeQueryEntityResultMapping($entityClass, [], 'e0'); |
|
|
|
|
259
|
|
|
|
260
|
1 |
|
return $this; |
261
|
|
|
} |
262
|
|
|
|
263
|
2 |
|
return $this->addNamedNativeQueryResultSetMapping($class, $queryMapping['resultSetMapping']); |
264
|
|
|
} |
265
|
|
|
|
266
|
|
|
/** |
267
|
|
|
* Adds the result set mapping of the results of native SQL queries to the result set. |
268
|
|
|
* |
269
|
|
|
* @param ClassMetadata $class |
270
|
|
|
* @param string $resultSetMappingName |
271
|
|
|
* |
272
|
|
|
* @return ResultSetMappingBuilder |
273
|
|
|
*/ |
274
|
2 |
|
public function addNamedNativeQueryResultSetMapping(ClassMetadata $class, $resultSetMappingName) |
275
|
|
|
{ |
276
|
2 |
|
$counter = 0; |
277
|
2 |
|
$resultMapping = $class->getSqlResultSetMapping($resultSetMappingName); |
278
|
2 |
|
$rootAlias = 'e' . $counter; |
279
|
|
|
|
280
|
2 |
|
if (isset($resultMapping['entities'])) { |
281
|
2 |
|
foreach ($resultMapping['entities'] as $key => $entityMapping) { |
282
|
2 |
|
$entityMapping['entityClass'] = ($entityMapping['entityClass'] === '__CLASS__') |
283
|
2 |
|
? $class->getClassName() |
284
|
1 |
|
: $entityMapping['entityClass'] |
285
|
|
|
; |
286
|
|
|
|
287
|
2 |
|
$classMetadata = $this->em->getClassMetadata($entityMapping['entityClass']); |
288
|
|
|
|
289
|
2 |
|
if ($class->getClassName() === $classMetadata->getClassName()) { |
290
|
2 |
|
$this->addEntityResult($classMetadata->getClassName(), $rootAlias); |
291
|
2 |
|
$this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $rootAlias); |
|
|
|
|
292
|
|
|
} else { |
293
|
1 |
|
$joinAlias = 'e' . ++$counter; |
294
|
|
|
|
295
|
1 |
|
$this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $joinAlias); |
296
|
|
|
|
297
|
1 |
|
foreach ($class->getDeclaredPropertiesIterator() as $fieldName => $association) { |
298
|
1 |
|
if (! ($association instanceof AssociationMetadata)) { |
299
|
|
|
continue; |
300
|
|
|
} |
301
|
|
|
|
302
|
1 |
|
if ($association->getTargetEntity() !== $classMetadata->getClassName()) { |
303
|
|
|
continue; |
304
|
|
|
} |
305
|
|
|
|
306
|
2 |
|
$this->addJoinedEntityResult($association->getTargetEntity(), $joinAlias, $rootAlias, $fieldName); |
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
} |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
if (isset($resultMapping['columns'])) { |
313
|
2 |
|
foreach ($resultMapping['columns'] as $entityMapping) { |
314
|
2 |
|
// @todo guilhermeblanco Collect type information from mapped column |
315
|
|
|
$this->addScalarResult($entityMapping['name'], $entityMapping['name'], Type::getType('string')); |
316
|
2 |
|
} |
317
|
|
|
} |
318
|
|
|
|
319
|
|
|
return $this; |
320
|
2 |
|
} |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* Adds the entity result mapping of the results of native SQL queries to the result set. |
324
|
|
|
* |
325
|
|
|
* @param ClassMetadata $classMetadata |
326
|
|
|
* @param array $entityMapping |
327
|
|
|
* @param string $alias |
328
|
|
|
* |
329
|
|
|
* @return ResultSetMappingBuilder |
330
|
|
|
* |
331
|
|
|
* @throws MappingException |
332
|
|
|
* @throws \InvalidArgumentException |
333
|
|
|
*/ |
334
|
|
|
public function addNamedNativeQueryEntityResultMapping(ClassMetadata $classMetadata, array $entityMapping, $alias) |
335
|
3 |
|
{ |
336
|
|
|
$platform = $this->em->getConnection()->getDatabasePlatform(); |
337
|
3 |
|
|
338
|
|
|
// Always fetch discriminator column. It's required for Proxy loading. We only adjust naming if provided |
339
|
|
|
if ($classMetadata->discriminatorColumn) { |
340
|
3 |
|
$discrColumn = $classMetadata->discriminatorColumn; |
341
|
|
|
$discrColumnName = $entityMapping['discriminatorColumn'] ?? $discrColumn->getColumnName(); |
342
|
|
|
$discrColumnType = $discrColumn->getType(); |
343
|
|
|
|
344
|
|
|
$this->setDiscriminatorColumn($alias, $discrColumnName); |
345
|
|
|
$this->addMetaResult($alias, $discrColumnName, $discrColumnName, false, $discrColumnType); |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
if (isset($entityMapping['fields']) && ! empty($entityMapping['fields'])) { |
349
|
3 |
|
foreach ($entityMapping['fields'] as $field) { |
350
|
1 |
|
$fieldName = $field['name']; |
351
|
1 |
|
$relation = null; |
352
|
1 |
|
|
353
|
|
|
if (strpos($fieldName, '.') !== false) { |
354
|
1 |
|
list($relation, $fieldName) = explode('.', $fieldName); |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
$property = $classMetadata->getProperty($fieldName); |
358
|
1 |
|
|
359
|
|
|
if (! $relation && $property instanceof FieldMetadata) { |
360
|
1 |
|
$this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->getClassName()); |
361
|
1 |
|
|
362
|
|
|
continue; |
363
|
1 |
|
} |
364
|
|
|
|
365
|
|
|
$property = $classMetadata->getProperty($relation); |
366
|
|
|
|
367
|
|
|
if (! $property) { |
368
|
|
|
throw new \InvalidArgumentException( |
369
|
|
|
"Entity '".$classMetadata->getClassName()."' has no field '".$relation."'. " |
370
|
|
|
); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
if ($property instanceof AssociationMetadata) { |
374
|
|
|
if (! $relation) { |
375
|
|
|
$this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->getClassName()); |
376
|
|
|
|
377
|
|
|
continue; |
378
|
|
|
} |
379
|
|
|
|
380
|
|
|
$joinAlias = $alias.$relation; |
|
|
|
|
381
|
|
|
$parentAlias = $alias; |
382
|
|
|
|
383
|
|
|
$this->addJoinedEntityResult($property->getTargetEntity(), $joinAlias, $parentAlias, $relation); |
|
|
|
|
384
|
|
|
$this->addFieldResult($joinAlias, $field['column'], $fieldName); |
385
|
1 |
|
} |
386
|
|
|
} |
387
|
|
|
} else { |
388
|
|
|
foreach ($classMetadata->getDeclaredPropertiesIterator() as $property) { |
389
|
2 |
|
switch (true) { |
390
|
|
|
case ($property instanceof FieldMetadata): |
|
|
|
|
391
|
2 |
|
$columnName = $property->getColumnName(); |
392
|
2 |
|
$columnAlias = $platform->getSQLResultCasing($columnName); |
393
|
2 |
|
|
394
|
|
|
if (isset($this->fieldMappings[$columnAlias])) { |
395
|
2 |
|
throw new \InvalidArgumentException( |
396
|
|
|
sprintf("The column '%s' conflicts with another column in the mapper.", $columnName) |
397
|
|
|
); |
398
|
|
|
} |
399
|
|
|
|
400
|
|
|
$this->addFieldResult($alias, $columnAlias, $property->getName()); |
401
|
2 |
|
break; |
402
|
2 |
|
|
403
|
|
|
case ($property instanceof ToOneAssociationMetadata && $property->isOwningSide()): |
|
|
|
|
404
|
2 |
|
$targetClass = $this->em->getClassMetadata($property->getTargetEntity()); |
405
|
2 |
|
|
406
|
|
|
foreach ($property->getJoinColumns() as $joinColumn) { |
407
|
2 |
|
/** @var JoinColumnMetadata $joinColumn */ |
408
|
|
|
$columnName = $joinColumn->getColumnName(); |
409
|
2 |
|
$referencedColumnName = $joinColumn->getReferencedColumnName(); |
410
|
2 |
|
$columnAlias = $platform->getSQLResultCasing($columnName); |
411
|
2 |
|
|
412
|
|
|
if (isset($this->metaMappings[$columnAlias])) { |
413
|
2 |
|
throw new \InvalidArgumentException( |
414
|
|
|
sprintf("The column '%s' conflicts with another column in the mapper.", $columnName) |
415
|
|
|
); |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
if (! $joinColumn->getType()) { |
419
|
2 |
|
$joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $targetClass, $this->em)); |
|
|
|
|
420
|
1 |
|
} |
421
|
|
|
|
422
|
|
|
$this->addMetaResult($alias, $columnAlias, $columnName, $property->isPrimaryKey(), $joinColumn->getType()); |
423
|
2 |
|
} |
424
|
|
|
break; |
425
|
2 |
|
} |
426
|
|
|
} |
427
|
|
|
} |
428
|
|
|
|
429
|
|
|
return $this; |
430
|
3 |
|
} |
431
|
|
|
|
432
|
|
|
/** |
433
|
|
|
* Generates the Select clause from this ResultSetMappingBuilder. |
434
|
|
|
* |
435
|
|
|
* Works only for all the entity results. The select parts for scalar |
436
|
|
|
* expressions have to be written manually. |
437
|
|
|
* |
438
|
|
|
* @param array $tableAliases |
439
|
|
|
* |
440
|
|
|
* @return string |
441
|
|
|
*/ |
442
|
|
|
public function generateSelectClause($tableAliases = []) |
443
|
6 |
|
{ |
444
|
|
|
$sql = ""; |
445
|
6 |
|
|
446
|
|
|
foreach ($this->columnOwnerMap as $columnName => $dqlAlias) { |
447
|
6 |
|
$tableAlias = $tableAliases[$dqlAlias] ?? $dqlAlias; |
448
|
6 |
|
|
449
|
|
|
if ($sql) { |
450
|
6 |
|
$sql .= ", "; |
451
|
6 |
|
} |
452
|
|
|
|
453
|
|
|
$sql .= $tableAlias . "."; |
454
|
6 |
|
|
455
|
|
|
if (isset($this->fieldMappings[$columnName])) { |
456
|
6 |
|
$class = $this->em->getClassMetadata($this->declaringClasses[$columnName]); |
457
|
6 |
|
$field = $this->fieldMappings[$columnName]; |
458
|
6 |
|
$sql .= $class->getProperty($field)->getColumnName(); |
|
|
|
|
459
|
6 |
|
} elseif (isset($this->metaMappings[$columnName])) { |
460
|
6 |
|
$sql .= $this->metaMappings[$columnName]; |
461
|
5 |
|
} elseif (isset($this->discriminatorColumns[$dqlAlias])) { |
462
|
1 |
|
$sql .= $this->discriminatorColumns[$dqlAlias]; |
463
|
1 |
|
} |
464
|
|
|
|
465
|
|
|
$sql .= " AS " . $columnName; |
466
|
6 |
|
} |
467
|
|
|
|
468
|
|
|
return $sql; |
469
|
6 |
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* @return string |
473
|
|
|
*/ |
474
|
|
|
public function __toString() |
475
|
1 |
|
{ |
476
|
|
|
return $this->generateSelectClause([]); |
477
|
1 |
|
} |
478
|
|
|
} |
479
|
|
|
|