1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/new/docs/en/dql-doctrine-query-language.txt

47 lines
1.4 KiB
Plaintext
Raw Normal View History

++ Introduction
++ SELECT queries
++ UPDATE queries
++ DELETE queries
++ FROM clause
2007-07-31 23:47:17 +04:00
++ JOIN syntax
2007-09-02 15:32:09 +04:00
++ INDEXBY keyword
++ WHERE clause
++ Conditional expressions
++ Functional Expressions
++ Subqueries
++ GROUP BY, HAVING clauses
++ ORDER BY clause
++ LIMIT and OFFSET clauses
++ Examples
2007-09-18 21:12:36 +04:00
++ The Query Registry
Doctrine_Query_Registry is a class for registering and naming queries. It helps with the organization of your applications queries and along with that it offers some very nice convenience stuff.
The queries are added using the add() method of the registry object. It takes two parameters, the query name and the actual DQL query.
<code type="php">
$r = Doctrine_Manager::getInstance()->getQueryRegistry();
$r->add('all-users', 'FROM User u');
</code>
+++ Namespaces
The Query registry supports namespaces. The namespace is separated from the actual name with / -mark. If the name of the namespace is a record name the given record has all the named queries availible in its local scope.
<code type="php">
$r = Doctrine_Manager::getInstance()->getQueryRegistry();
$r->add('User/all', 'FROM User u');
$r->add('User/byName', 'FROM User u WHERE u.name = ?');
$user = new User();
2007-09-18 21:26:56 +04:00
// find the user named Jack Daniels
$user = $user->findOne('byName', array('Jack Daniels'));
2007-09-18 21:12:36 +04:00
2007-09-18 21:26:56 +04:00
// find all users
$users = $user->find('all');
2007-09-18 21:12:36 +04:00
</code>
2007-09-02 15:32:09 +04:00
++ BNF