You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$query = $em->createQuery('SELECT u, a, p, c FROM CmsUser u JOIN u.articles a JOIN u.phonenumbers p JOIN a.comments c');
374
399
$users = $query->getResult();
375
400
376
-
BETWEEN in WHERE clause:
401
+
BETWEEN in WHERE clause
402
+
^^^^^^^^^^^^^^^^^^^^^^^
377
403
378
404
.. code-block:: php
379
405
@@ -383,15 +409,17 @@ BETWEEN in WHERE clause:
383
409
$query->setParameter(2, 321);
384
410
$usernames = $query->getResult();
385
411
386
-
DQL Functions in WHERE clause:
412
+
DQL Functions in WHERE clause
413
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
387
414
388
415
.. code-block:: php
389
416
390
417
<?php
391
418
$query = $em->createQuery("SELECT u.name FROM CmsUser u WHERE TRIM(u.name) = 'someone'");
392
419
$usernames = $query->getResult();
393
420
394
-
IN() Expression:
421
+
IN() Expression
422
+
^^^^^^^^^^^^^^^
395
423
396
424
.. code-block:: php
397
425
@@ -405,7 +433,8 @@ IN() Expression:
405
433
$query = $em->createQuery('SELECT u FROM CmsUser u WHERE u.id NOT IN (1)');
406
434
$users = $query->getResult();
407
435
408
-
CONCAT() DQL Function:
436
+
CONCAT() DQL Function
437
+
^^^^^^^^^^^^^^^^^^^^^
409
438
410
439
.. code-block:: php
411
440
@@ -419,14 +448,16 @@ CONCAT() DQL Function:
419
448
$idUsernames = $query->getResult();
420
449
421
450
EXISTS in WHERE clause with correlated Subquery
451
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
422
452
423
453
.. code-block:: php
424
454
425
455
<?php
426
456
$query = $em->createQuery('SELECT u.id FROM CmsUser u WHERE EXISTS (SELECT p.phonenumber FROM CmsPhonenumber p WHERE p.user = u.id)');
427
457
$ids = $query->getResult();
428
458
429
-
Get all users who are members of $group.
459
+
Get all users who are members of $group
460
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
430
461
431
462
.. code-block:: php
432
463
@@ -436,6 +467,7 @@ Get all users who are members of $group.
436
467
$ids = $query->getResult();
437
468
438
469
Get all users that have more than 1 phonenumber
470
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
439
471
440
472
.. code-block:: php
441
473
@@ -444,15 +476,19 @@ Get all users that have more than 1 phonenumber
444
476
$users = $query->getResult();
445
477
446
478
Get all users that have no phonenumber
479
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
447
480
448
481
.. code-block:: php
449
482
450
483
<?php
451
484
$query = $em->createQuery('SELECT u FROM CmsUser u WHERE u.phonenumbers IS EMPTY');
452
485
$users = $query->getResult();
453
486
454
-
Get all instances of a specific type, for use with inheritance
455
-
hierarchies:
487
+
Get all instances of a specific type
488
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
489
+
490
+
Get all instances of a specific type, for use with inheritance hierarchies. These queries can be useful for
491
+
:doc:`inheritance mapping <inheritance-mapping>`.
456
492
457
493
.. versionadded:: 2.1
458
494
@@ -463,7 +499,10 @@ hierarchies:
463
499
$query = $em->createQuery('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u INSTANCE OF ?1');
464
500
$query = $em->createQuery('SELECT u FROM Doctrine\Tests\Models\Company\CompanyPerson u WHERE u NOT INSTANCE OF ?1');
465
501
466
-
Get all users visible on a given website that have chosen certain gender:
502
+
Using IDENTITY() in queries
503
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
504
+
505
+
Get all users visible on a given website that have chosen certain gender.
467
506
468
507
.. versionadded:: 2.2
469
508
@@ -474,13 +513,16 @@ Get all users visible on a given website that have chosen certain gender:
474
513
475
514
.. versionadded:: 2.4
476
515
477
-
Starting with 2.4, the IDENTITY() DQL function also works for composite primary keys:
516
+
Starting with 2.4, the IDENTITY() DQL function also works for composite primary keys
478
517
479
518
.. code-block:: php
480
519
481
520
<?php
482
521
$query = $em->createQuery("SELECT IDENTITY(c.location, 'latitude') AS latitude, IDENTITY(c.location, 'longitude') AS longitude FROM Checkpoint c WHERE c.user = ?1");
483
522
523
+
Arbitrary Join
524
+
^^^^^^^^^^^^^^
525
+
484
526
Joins between entities without associations were not possible until version
485
527
2.4, where you can generate an arbitrary join with the following syntax:
0 commit comments