Skip to content
This repository

[DDC-1270] Fixed invalid expr()->*() function calls; Added isNull and isN #35

Merged
merged 1 commit into from over 2 years ago

2 participants

Michael Ridgway Benjamin Eberlei
Michael Ridgway

Fixed invalid calls to $qb->exp()->select() and other similar functions. Added isNull and isNotNull functions. Fixed casing on orX and andX functions.

http://www.doctrine-project.org/jira/browse/DDC-1270

Benjamin Eberlei beberlei merged commit c0860a6 into from July 26, 2011
Benjamin Eberlei beberlei closed this July 26, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 11, 2011
Michael Ridgway [DDC-1270] Fixed invalid expr()->*() function calls; Added isNull and…
… isNotNull functions; Fixed casing on orX and andX
175faeb
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 20 additions and 14 deletions. Show diff stats Hide diff stats

  1. 34  en/reference/query-builder.rst
34  en/reference/query-builder.rst
Source Rendered
@@ -240,10 +240,10 @@ To simplify some of these efforts, we introduce what we call as
240 240
 The Expr class
241 241
 ^^^^^^^^^^^^^^
242 242
 
243  
-To workaround most of the issues that ``add()`` method may cause,
  243
+To workaround some of the issues that ``add()`` method may cause,
244 244
 Doctrine created a class that can be considered as a helper for
245  
-building queries. This class is called ``Expr``, which provides a
246  
-set of useful static methods to help building queries:
  245
+building expressions. This class is called ``Expr``, which provides a
  246
+set of useful methods to help build expressions:
247 247
 
248 248
 .. code-block:: php
249 249
 
@@ -251,13 +251,13 @@ set of useful static methods to help building queries:
251 251
     // $qb instanceof QueryBuilder
252 252
     
253 253
     // example8: QueryBuilder port of: "SELECT u FROM User u WHERE u.id = ? OR u.nickname LIKE ? ORDER BY u.surname DESC" using Expr class
254  
-    $qb->add('select', $qb->expr()->select('u'))
255  
-       ->add('from', $qb->expr()->from('User', 'u'))
256  
-       ->add('where', $qb->expr()->orx(
  254
+    $qb->add('select', new Expr\Select(array('u')))
  255
+       ->add('from', new Expr\From('User', 'u'))
  256
+       ->add('where', $qb->expr()->orX(
257 257
            $qb->expr()->eq('u.id', '?1'),
258 258
            $qb->expr()->like('u.nickname', '?2')
259 259
        ))
260  
-       ->add('orderBy', $qb->expr()->orderBy('u.surname', 'ASC'));
  260
+       ->add('orderBy', new Expr\OrderBy('u.name', 'ASC'));
261 261
 
262 262
 Although it still sounds complex, the ability to programmatically
263 263
 create conditions are the main feature of ``Expr``. Here it is a
@@ -270,11 +270,11 @@ complete list of supported helper methods available:
270 270
     {
271 271
         /** Conditional objects **/        
272 272
     
273  
-        // Example - $qb->expr()->andx($cond1 [, $condN])->add(...)->...
274  
-        public function andx($x = null); // Returns Expr\Andx instance
  273
+        // Example - $qb->expr()->andX($cond1 [, $condN])->add(...)->...
  274
+        public function andX($x = null); // Returns Expr\AndX instance
275 275
     
276  
-        // Example - $qb->expr()->orx($cond1 [, $condN])->add(...)->...
277  
-        public function orx($x = null); // Returns Expr\Orx instance
  276
+        // Example - $qb->expr()->orX($cond1 [, $condN])->add(...)->...
  277
+        public function orX($x = null); // Returns Expr\OrX instance
278 278
     
279 279
     
280 280
         /** Comparison objects **/
@@ -296,6 +296,12 @@ complete list of supported helper methods available:
296 296
     
297 297
         // Example - $qb->expr()->gte('u.id', '?1') => u.id >= ?1
298 298
         public function gte($x, $y); // Returns Expr\Comparison instance
  299
+
  300
+        // Example - $qb->expr()->isNull('u.id') => u.id IS NULL
  301
+        public function isNull($x); // Returns string
  302
+
  303
+        // Example - $qb->expr()->isNotNull('u.id') => u.id IS NOT NULL
  304
+        public function isNotNull($x); // Returns string
299 305
     
300 306
     
301 307
         /** Arithmetic objects **/
@@ -425,7 +431,7 @@ suggested standard way to build queries:
425 431
     // example8: QueryBuilder port of: "SELECT u FROM User u WHERE u.id = ?1 OR u.nickname LIKE ?2 ORDER BY u.surname DESC" using QueryBuilder helper methods
426 432
     $qb->select(array('u')) // string 'u' is converted to array internally
427 433
        ->from('User', 'u')
428  
-       ->where($qb->expr()->orx(
  434
+       ->where($qb->expr()->orX(
429 435
            $qb->expr()->eq('u.id', '?1'),
430 436
            $qb->expr()->like('u.nickname', '?2')
431 437
        ))
@@ -469,11 +475,11 @@ Here is a complete list of helper methods available in
469 475
         // NOTE: ->where() overrides all previously set conditions
470 476
         //
471 477
         // Example - $qb->where('u.firstName = ?1', $qb->expr()->eq('u.surname', '?2'))
472  
-        // Example - $qb->where($qb->expr()->andx($qb->expr()->eq('u.firstName', '?1'), $qb->expr()->eq('u.surname', '?2')))
  478
+        // Example - $qb->where($qb->expr()->andX($qb->expr()->eq('u.firstName', '?1'), $qb->expr()->eq('u.surname', '?2')))
473 479
         // Example - $qb->where('u.firstName = ?1 AND u.surname = ?2')    
474 480
         public function where($where);
475 481
     
476  
-        // Example - $qb->andWhere($qb->expr()->orx($qb->expr()->lte('u.age', 40), 'u.numChild = 0'))    
  482
+        // Example - $qb->andWhere($qb->expr()->orX($qb->expr()->lte('u.age', 40), 'u.numChild = 0'))
477 483
         public function andWhere($where);
478 484
     
479 485
         // Example - $qb->orWhere($qb->expr()->between('u.id', 1, 10));
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.