from-clause.txt 880 Bytes
Newer Older
1 2
Syntax:

jackbravo's avatar
jackbravo committed
3
<code type="sql">
4 5 6 7 8
FROM <component_reference> [[LEFT | INNER] JOIN <component_reference>] ...
</code>

The {{FROM}} clause indicates the component or components from which to retrieve records. If you name more than one component, you are performing a join. For each table specified, you can optionally specify an alias.

zYne's avatar
zYne committed
9
Consider the following DQL query:
jackbravo's avatar
jackbravo committed
10
<code type="sql">
zYne's avatar
zYne committed
11 12
FROM User u
</code>
13

zYne's avatar
zYne committed
14
Here 'User' is the name of the class (component) and 'u' is the alias. You should always use short aliases, since most of the time those make the query much shorther and also because when using for example caching the cached form of the query takes less space when short aliases are being used. 
15

zYne's avatar
zYne committed
16
The following example shows how to fetch all records from class 'User'.
17

zYne's avatar
zYne committed
18 19 20 21 22
<code type="php">
$users = Doctrine_Query::create()
         ->from('User u')
         ->execute();
</code>