Working with objects - Component overview - Query - Introduction.php 954 Bytes
Newer Older
1

hansbrix's avatar
hansbrix committed
2
DQL (Doctrine Query Language) is a object query language which allows
lsmith's avatar
lsmith committed
3 4
you to find objects. DQL understands things like object relationships, polymorphism and
inheritance (including column aggregation inheritance).
hansbrix's avatar
hansbrix committed
5
For more info about DQL see the actual DQL chapter.
6

hansbrix's avatar
hansbrix committed
7 8


lsmith's avatar
lsmith committed
9
Doctrine_Query along with Doctrine_Expression provide an easy-to-use wrapper for writing DQL queries. Creating a new
hansbrix's avatar
hansbrix committed
10 11 12 13 14 15 16 17 18 19 20 21 22
query object can be done by either using the new operator or by calling create method. The create method exists for allowing easy
method call chaining.

<code type="php">
// initalizing a new Doctrine_Query (using the current connection)
$q = new Doctrine_Query();

// initalizing a new Doctrine_Query (using custom connection parameter)
// here $conn is an instance of Doctrine_Connection
$q = new Doctrine_Query($conn);

// an example using the create method
// here we simple fetch all users
lsmith's avatar
lsmith committed
23
$users = new Doctrine_Query::create()->from('User')->execute();
hansbrix's avatar
hansbrix committed
24
</code>