1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/docs/Working with objects - Component overview - Query - Relation operators.php
2007-04-13 21:49:11 +00:00

28 lines
776 B
PHP

Doctrine provides two relation operators: '.' aka dot and ':' aka colon.
The dot-operator is used for SQL LEFT JOINs and the colon-operator is used
for SQL INNER JOINs. Basically you should use dot operator if you want for example
to select all users and their phonenumbers AND it doesn't matter if the users actually have any phonenumbers.
On the other hand if you want to select only the users which actually have phonenumbers you should use the colon-operator.
<code type="php">
$query->from('User u')->innerJoin('u.Email e');
$query->execute();
// executed SQL query:
// SELECT ... FROM user INNER JOIN email ON ...
$query->from('User u')->leftJoin('u.Email e');
$query->execute();
// executed SQL query:
// SELECT ... FROM user LEFT JOIN email ON ...
</code>