Passed
Push — master ( e47dd8...3ef27a )
by
unknown
13:30
created

Query::__sleep()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
 * It is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License, either version 2
8
 * of the License, or any later version.
9
 *
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
 * The TYPO3 project - inspiring people to share!
14
 */
15
16
namespace TYPO3\CMS\Extbase\Persistence\Generic;
17
18
use TYPO3\CMS\Core\Utility\GeneralUtility;
19
use TYPO3\CMS\Extbase\Object\ObjectManager;
20
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
21
use TYPO3\CMS\Extbase\Persistence\Generic\Exception\InvalidNumberOfConstraintsException;
22
use TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnexpectedTypeException;
23
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory;
24
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface;
25
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory;
26
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\SelectorInterface;
27
use TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface;
28
use TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface;
29
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
30
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
31
use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility;
32
33
/**
34
 * The Query class used to run queries against the database
35
 */
36
class Query implements QueryInterface
37
{
38
    /**
39
     * An inner join.
40
     */
41
    const JCR_JOIN_TYPE_INNER = '{http://www.jcp.org/jcr/1.0}joinTypeInner';
42
43
    /**
44
     * A left-outer join.
45
     */
46
    const JCR_JOIN_TYPE_LEFT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeLeftOuter';
47
48
    /**
49
     * A right-outer join.
50
     */
51
    const JCR_JOIN_TYPE_RIGHT_OUTER = '{http://www.jcp.org/jcr/1.0}joinTypeRightOuter';
52
53
    /**
54
     * Charset of strings in QOM
55
     */
56
    const CHARSET = 'utf-8';
57
58
    /**
59
     * @var string
60
     */
61
    protected $type;
62
63
    /**
64
     * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
65
     */
66
    protected $objectManager;
67
68
    /**
69
     * @var \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory
70
     */
71
    protected $dataMapFactory;
72
73
    /**
74
     * @var \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface
75
     */
76
    protected $persistenceManager;
77
78
    /**
79
     * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory
80
     */
81
    protected $qomFactory;
82
83
    /**
84
     * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface
85
     */
86
    protected $source;
87
88
    /**
89
     * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface
90
     */
91
    protected $constraint;
92
93
    /**
94
     * @var \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement
95
     */
96
    protected $statement;
97
98
    /**
99
     * @var int[]
100
     */
101
    protected $orderings = [];
102
103
    /**
104
     * @var int
105
     */
106
    protected $limit;
107
108
    /**
109
     * @var int
110
     */
111
    protected $offset;
112
113
    /**
114
     * The query settings.
115
     *
116
     * @var QuerySettingsInterface
117
     */
118
    protected $querySettings;
119
120
    /**
121
     * @var QueryInterface|null
122
     * @internal
123
     */
124
    protected $parentQuery;
125
126
    /**
127
     * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
128
     */
129
    public function injectObjectManager(ObjectManagerInterface $objectManager)
130
    {
131
        $this->objectManager = $objectManager;
132
    }
133
134
    /**
135
     * @param \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory $dataMapFactory
136
     */
137
    public function injectDataMapFactory(DataMapFactory $dataMapFactory)
138
    {
139
        $this->dataMapFactory = $dataMapFactory;
140
    }
141
142
    /**
143
     * @param \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface $persistenceManager
144
     */
145
    public function injectPersistenceManager(PersistenceManagerInterface $persistenceManager)
146
    {
147
        $this->persistenceManager = $persistenceManager;
148
    }
149
150
    /**
151
     * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory $qomFactory
152
     */
153
    public function injectQomFactory(QueryObjectModelFactory $qomFactory)
154
    {
155
        $this->qomFactory = $qomFactory;
156
    }
157
158
    /**
159
     * Constructs a query object working on the given class name
160
     *
161
     * @param string $type
162
     */
163
    public function __construct($type)
164
    {
165
        $this->type = $type;
166
    }
167
168
    /**
169
     * @return ?QueryInterface
170
     * @internal
171
     */
172
    public function getParentQuery(): ?QueryInterface
173
    {
174
        return $this->parentQuery;
175
    }
176
177
    /**
178
     * @param ?QueryInterface $parentQuery
179
     * @internal
180
     */
181
    public function setParentQuery(?QueryInterface $parentQuery): void
182
    {
183
        $this->parentQuery = $parentQuery;
184
    }
185
186
    /**
187
     * Sets the Query Settings. These Query settings must match the settings expected by
188
     * the specific Storage Backend.
189
     *
190
     * @param QuerySettingsInterface $querySettings The Query Settings
191
     */
192
    public function setQuerySettings(QuerySettingsInterface $querySettings)
193
    {
194
        $this->querySettings = $querySettings;
195
    }
196
197
    /**
198
     * Returns the Query Settings.
199
     *
200
     * @throws Exception
201
     * @return QuerySettingsInterface $querySettings The Query Settings
202
     */
203
    public function getQuerySettings()
204
    {
205
        if (!$this->querySettings instanceof QuerySettingsInterface) {
0 ignored issues
show
introduced by
$this->querySettings is always a sub-type of TYPO3\CMS\Extbase\Persis...\QuerySettingsInterface.
Loading history...
206
            throw new Exception('Tried to get the query settings without setting them before.', 1248689115);
207
        }
208
        return $this->querySettings;
209
    }
210
211
    /**
212
     * Returns the type this query cares for.
213
     *
214
     * @return string
215
     */
216
    public function getType()
217
    {
218
        return $this->type;
219
    }
220
221
    /**
222
     * Sets the source to fetch the result from
223
     *
224
     * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface $source
225
     */
226
    public function setSource(SourceInterface $source)
227
    {
228
        $this->source = $source;
229
    }
230
231
    /**
232
     * Returns the selector's name or an empty string, if the source is not a selector
233
     * @todo This has to be checked at another place
234
     *
235
     * @return string The selector name
236
     */
237
    protected function getSelectorName()
238
    {
239
        $source = $this->getSource();
240
        if ($source instanceof SelectorInterface) {
241
            return $source->getSelectorName();
242
        }
243
        return '';
244
    }
245
246
    /**
247
     * Gets the node-tuple source for this query.
248
     *
249
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\SourceInterface the node-tuple source; non-null
250
     */
251
    public function getSource()
252
    {
253
        if ($this->source === null) {
254
            $this->source = $this->qomFactory->selector($this->getType(), $this->dataMapFactory->buildDataMap($this->getType())->getTableName());
255
        }
256
        return $this->source;
257
    }
258
259
    /**
260
     * Executes the query against the database and returns the result
261
     *
262
     * @param bool $returnRawQueryResult avoids the object mapping by the persistence
263
     * @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface|array The query result object or an array if $returnRawQueryResult is TRUE
264
     */
265
    public function execute($returnRawQueryResult = false)
266
    {
267
        if ($returnRawQueryResult) {
268
            return $this->persistenceManager->getObjectDataByQuery($this);
269
        }
270
        return $this->objectManager->get(QueryResultInterface::class, $this);
271
    }
272
273
    /**
274
     * Sets the property names to order the result by. Expected like this:
275
     * array(
276
     * 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
277
     * 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
278
     * )
279
     * where 'foo' and 'bar' are property names.
280
     *
281
     * @param array $orderings The property names to order by
282
     * @return QueryInterface
283
     */
284
    public function setOrderings(array $orderings)
285
    {
286
        $this->orderings = $orderings;
287
        return $this;
288
    }
289
290
    /**
291
     * Returns the property names to order the result by. Like this:
292
     * array(
293
     * 'foo' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING,
294
     * 'bar' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING
295
     * )
296
     *
297
     * @return int
298
     */
299
    public function getOrderings()
300
    {
301
        return $this->orderings;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->orderings returns the type integer[] which is incompatible with the documented return type integer.
Loading history...
302
    }
303
304
    /**
305
     * Sets the maximum size of the result set to limit. Returns $this to allow
306
     * for chaining (fluid interface)
307
     *
308
     * @param int $limit
309
     * @throws \InvalidArgumentException
310
     * @return QueryInterface
311
     */
312
    public function setLimit($limit)
313
    {
314
        if (!is_int($limit) || $limit < 1) {
0 ignored issues
show
introduced by
The condition is_int($limit) is always true.
Loading history...
315
            throw new \InvalidArgumentException('The limit must be an integer >= 1', 1245071870);
316
        }
317
        $this->limit = $limit;
318
        return $this;
319
    }
320
321
    /**
322
     * Resets a previously set maximum size of the result set. Returns $this to allow
323
     * for chaining (fluid interface)
324
     *
325
     * @return QueryInterface
326
     */
327
    public function unsetLimit()
328
    {
329
        unset($this->limit);
330
        return $this;
331
    }
332
333
    /**
334
     * Returns the maximum size of the result set to limit.
335
     *
336
     * @return int
337
     */
338
    public function getLimit()
339
    {
340
        return $this->limit;
341
    }
342
343
    /**
344
     * Sets the start offset of the result set to offset. Returns $this to
345
     * allow for chaining (fluid interface)
346
     *
347
     * @param int $offset
348
     * @throws \InvalidArgumentException
349
     * @return QueryInterface
350
     */
351
    public function setOffset($offset)
352
    {
353
        if (!is_int($offset) || $offset < 0) {
0 ignored issues
show
introduced by
The condition is_int($offset) is always true.
Loading history...
354
            throw new \InvalidArgumentException('The offset must be a positive integer', 1245071872);
355
        }
356
        $this->offset = $offset;
357
        return $this;
358
    }
359
360
    /**
361
     * Returns the start offset of the result set.
362
     *
363
     * @return int
364
     */
365
    public function getOffset()
366
    {
367
        return $this->offset;
368
    }
369
370
    /**
371
     * The constraint used to limit the result set. Returns $this to allow
372
     * for chaining (fluid interface)
373
     *
374
     * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint
375
     * @return QueryInterface
376
     */
377
    public function matching($constraint)
378
    {
379
        $this->constraint = $constraint;
380
        return $this;
381
    }
382
383
    /**
384
     * Sets the statement of this query. If you use this, you will lose the abstraction from a concrete storage
385
     * backend (database).
386
     *
387
     * @param string|\TYPO3\CMS\Core\Database\Query\QueryBuilder|\Doctrine\DBAL\Statement $statement The statement
388
     * @param array $parameters An array of parameters. These will be bound to placeholders '?' in the $statement.
389
     * @return QueryInterface
390
     */
391
    public function statement($statement, array $parameters = [])
392
    {
393
        $this->statement = $this->qomFactory->statement($statement, $parameters);
0 ignored issues
show
Bug introduced by
It seems like $statement can also be of type Doctrine\DBAL\Statement; however, parameter $statement of TYPO3\CMS\Extbase\Persis...delFactory::statement() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

393
        $this->statement = $this->qomFactory->statement(/** @scrutinizer ignore-type */ $statement, $parameters);
Loading history...
394
        return $this;
395
    }
396
397
    /**
398
     * Returns the statement of this query.
399
     *
400
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\Statement
401
     */
402
    public function getStatement()
403
    {
404
        return $this->statement;
405
    }
406
407
    /**
408
     * Gets the constraint for this query.
409
     *
410
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface|null the constraint, or null if none
411
     */
412
    public function getConstraint()
413
    {
414
        return $this->constraint;
415
    }
416
417
    /**
418
     * Performs a logical conjunction of the given constraints. The method takes one or more constraints and concatenates them with a boolean AND.
419
     * It also accepts a single array of constraints to be concatenated.
420
     *
421
     * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
422
     * @throws Exception\InvalidNumberOfConstraintsException
423
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface
424
     */
425
    public function logicalAnd($constraint1)
426
    {
427
        if (is_array($constraint1)) {
428
            $resultingConstraint = array_shift($constraint1);
429
            $constraints = $constraint1;
430
        } else {
431
            $constraints = func_get_args();
432
            $resultingConstraint = array_shift($constraints);
433
        }
434
        if ($resultingConstraint === null) {
435
            throw new InvalidNumberOfConstraintsException('There must be at least one constraint or a non-empty array of constraints given.', 1268056288);
436
        }
437
        foreach ($constraints as $constraint) {
438
            $resultingConstraint = $this->qomFactory->_and($resultingConstraint, $constraint);
439
        }
440
        return $resultingConstraint;
441
    }
442
443
    /**
444
     * Performs a logical disjunction of the two given constraints
445
     *
446
     * @param mixed $constraint1 The first of multiple constraints or an array of constraints.
447
     * @throws Exception\InvalidNumberOfConstraintsException
448
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\OrInterface
449
     */
450
    public function logicalOr($constraint1)
451
    {
452
        if (is_array($constraint1)) {
453
            $resultingConstraint = array_shift($constraint1);
454
            $constraints = $constraint1;
455
        } else {
456
            $constraints = func_get_args();
457
            $resultingConstraint = array_shift($constraints);
458
        }
459
        if ($resultingConstraint === null) {
460
            throw new InvalidNumberOfConstraintsException('There must be at least one constraint or a non-empty array of constraints given.', 1268056289);
461
        }
462
        foreach ($constraints as $constraint) {
463
            $resultingConstraint = $this->qomFactory->_or($resultingConstraint, $constraint);
464
        }
465
        return $resultingConstraint;
466
    }
467
468
    /**
469
     * Performs a logical negation of the given constraint
470
     *
471
     * @param \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface $constraint Constraint to negate
472
     * @throws \RuntimeException
473
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\NotInterface
474
     */
475
    public function logicalNot(ConstraintInterface $constraint)
476
    {
477
        return $this->qomFactory->not($constraint);
478
    }
479
480
    /**
481
     * Returns an equals criterion used for matching objects against a query
482
     *
483
     * @param string $propertyName The name of the property to compare against
484
     * @param mixed $operand The value to compare with
485
     * @param bool $caseSensitive Whether the equality test should be done case-sensitive
486
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
487
     */
488
    public function equals($propertyName, $operand, $caseSensitive = true)
489
    {
490
        if (is_object($operand) || $caseSensitive) {
491
            $comparison = $this->qomFactory->comparison(
492
                $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
493
                QueryInterface::OPERATOR_EQUAL_TO,
494
                $operand
495
            );
496
        } else {
497
            $comparison = $this->qomFactory->comparison(
498
                $this->qomFactory->lowerCase($this->qomFactory->propertyValue($propertyName, $this->getSelectorName())),
499
                QueryInterface::OPERATOR_EQUAL_TO,
500
                mb_strtolower($operand, \TYPO3\CMS\Extbase\Persistence\Generic\Query::CHARSET)
0 ignored issues
show
Bug introduced by
mb_strtolower($operand, ...Generic\Query::CHARSET) of type string is incompatible with the type TYPO3\CMS\Extbase\Persis...\StaticOperandInterface expected by parameter $operand2 of TYPO3\CMS\Extbase\Persis...elFactory::comparison(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

500
                /** @scrutinizer ignore-type */ mb_strtolower($operand, \TYPO3\CMS\Extbase\Persistence\Generic\Query::CHARSET)
Loading history...
501
            );
502
        }
503
        return $comparison;
504
    }
505
506
    /**
507
     * Returns a like criterion used for matching objects against a query
508
     *
509
     * @param string $propertyName The name of the property to compare against
510
     * @param mixed $operand The value to compare with
511
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
512
     */
513
    public function like($propertyName, $operand)
514
    {
515
        return $this->qomFactory->comparison(
516
            $this->qomFactory->propertyValue($propertyName, $this->getSelectorName()),
517
            QueryInterface::OPERATOR_LIKE,
518
            $operand
519
        );
520
    }
521
522
    /**
523
     * Returns a "contains" criterion used for matching objects against a query.
524
     * It matches if the multivalued property contains the given operand.
525
     *
526
     * @param string $propertyName The name of the (multivalued) property to compare against
527
     * @param mixed $operand The value to compare with
528
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
529
     */
530
    public function contains($propertyName, $operand)
531
    {
532
        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_CONTAINS, $operand);
533
    }
534
535
    /**
536
     * Returns an "in" criterion used for matching objects against a query. It
537
     * matches if the property's value is contained in the multivalued operand.
538
     *
539
     * @param string $propertyName The name of the property to compare against
540
     * @param mixed $operand The value to compare with, multivalued
541
     * @throws Exception\UnexpectedTypeException
542
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
543
     */
544
    public function in($propertyName, $operand)
545
    {
546
        if (!TypeHandlingUtility::isValidTypeForMultiValueComparison($operand)) {
547
            throw new UnexpectedTypeException('The "in" operator must be given a multivalued operand (array, ArrayAccess, Traversable).', 1264678095);
548
        }
549
        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_IN, $operand);
550
    }
551
552
    /**
553
     * Returns a less than criterion used for matching objects against a query
554
     *
555
     * @param string $propertyName The name of the property to compare against
556
     * @param mixed $operand The value to compare with
557
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
558
     */
559
    public function lessThan($propertyName, $operand)
560
    {
561
        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_LESS_THAN, $operand);
562
    }
563
564
    /**
565
     * Returns a less or equal than criterion used for matching objects against a query
566
     *
567
     * @param string $propertyName The name of the property to compare against
568
     * @param mixed $operand The value to compare with
569
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
570
     */
571
    public function lessThanOrEqual($propertyName, $operand)
572
    {
573
        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_LESS_THAN_OR_EQUAL_TO, $operand);
574
    }
575
576
    /**
577
     * Returns a greater than criterion used for matching objects against a query
578
     *
579
     * @param string $propertyName The name of the property to compare against
580
     * @param mixed $operand The value to compare with
581
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
582
     */
583
    public function greaterThan($propertyName, $operand)
584
    {
585
        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_GREATER_THAN, $operand);
586
    }
587
588
    /**
589
     * Returns a greater than or equal criterion used for matching objects against a query
590
     *
591
     * @param string $propertyName The name of the property to compare against
592
     * @param mixed $operand The value to compare with
593
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\ComparisonInterface
594
     */
595
    public function greaterThanOrEqual($propertyName, $operand)
596
    {
597
        return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, $this->getSelectorName()), QueryInterface::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $operand);
598
    }
599
600
    /**
601
     * Returns a greater than or equal criterion used for matching objects against a query
602
     *
603
     * @param string $propertyName The name of the property to compare against
604
     * @param mixed $operandLower The value of the lower boundary to compare against
605
     * @param mixed $operandUpper The value of the upper boundary to compare against
606
     * @return \TYPO3\CMS\Extbase\Persistence\Generic\Qom\AndInterface
607
     * @throws \TYPO3\CMS\Extbase\Persistence\Generic\Exception\InvalidNumberOfConstraintsException
608
     */
609
    public function between($propertyName, $operandLower, $operandUpper)
610
    {
611
        return $this->logicalAnd(
612
            $this->greaterThanOrEqual($propertyName, $operandLower),
613
            $this->lessThanOrEqual($propertyName, $operandUpper)
614
        );
615
    }
616
617
    /**
618
     * @internal only to be used within Extbase, not part of TYPO3 Core API.
619
     */
620
    public function __wakeup()
621
    {
622
        $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
623
        $this->persistenceManager = $this->objectManager->get(PersistenceManagerInterface::class);
624
        $this->dataMapFactory = $this->objectManager->get(DataMapFactory::class);
625
        $this->qomFactory = $this->objectManager->get(QueryObjectModelFactory::class);
626
    }
627
628
    /**
629
     * @return array
630
     * @internal only to be used within Extbase, not part of TYPO3 Core API.
631
     */
632
    public function __sleep()
633
    {
634
        return ['type', 'source', 'constraint', 'statement', 'orderings', 'limit', 'offset', 'querySettings'];
635
    }
636
637
    /**
638
     * Returns the query result count.
639
     *
640
     * @return int The query result count
641
     */
642
    public function count()
643
    {
644
        return $this->execute()->count();
645
    }
646
}
647