@@ -388,7 +388,7 @@ public function from($tables = [], $overwrite = false) {
388
388
}
389
389
390
390
/**
391
- * Adds a single or multiple tables to be used as JOIN clauses this query.
391
+ * Adds a single or multiple tables to be used as JOIN clauses to this query.
392
392
* Tables can be passed as an array of strings, an array describing the
393
393
* join parts, an array with multiple join descriptions, or a single string.
394
394
*
@@ -426,18 +426,18 @@ public function from($tables = [], $overwrite = false) {
426
426
* 'p' => [
427
427
* 'table' => 'publishers',
428
428
* 'type' => 'INNER',
429
- * 'conditions' => 'b.publisher_id = p.id AND p.name = "Cake Software Foundation"'
429
+ * 'conditions' => 'p.id = b.publisher_id AND p.name = "Cake Software Foundation"'
430
430
* ]
431
431
* ]);
432
432
* // LEFT JOIN authors a ON a.id = b.author_id
433
- * // INNER JOIN publishers p ON b.publisher_id = p.id AND p.name = "Cake Software Foundation"
433
+ * // INNER JOIN publishers p ON p.id = b.publisher_id AND p.name = "Cake Software Foundation"
434
434
* }}}
435
435
*
436
436
* ### Using conditions and types
437
437
*
438
438
* Conditions can be expressed, as in the examples above, using a string for comparing
439
439
* columns, or string with already quoted literal values. Additionally it is
440
- * possible to using conditions expressed in arrays or expression objects.
440
+ * possible to use conditions expressed in arrays or expression objects.
441
441
*
442
442
* When using arrays for expressing conditions, it is often desirable to convert
443
443
* the literal values to the correct database representation. This is achieved
@@ -513,19 +513,33 @@ public function join($tables = null, $types = [], $overwrite = false) {
513
513
/**
514
514
* Adds a single LEFT JOIN clause to the query.
515
515
*
516
+ * This is a shorthand method for building joins via `join()`.
517
+ *
518
+ * The table name can be passed as a string, or as an array in case it needs to
519
+ * be aliased:
520
+ *
516
521
* {{{
517
- * // LEFT JOIN authors ON posts.author_id = authors.id
518
- * $query->leftJoin('authors', ['posts.author_id = authors.id']);
522
+ * // LEFT JOIN authors ON authors.id = posts.author_id
523
+ * $query->leftJoin('authors', 'authors.id = posts.author_id');
524
+ *
525
+ * // LEFT JOIN authors a ON a.id = posts.author_id
526
+ * $query->leftJoin(['a' => 'authors'], 'a.id = posts.author_id');
519
527
* }}}
520
528
*
521
- * You can pass an array in the first parameter if you need to alias
522
- * the table for the join:
529
+ * Conditions can be passed as strings, arrays, or expression objects. When
530
+ * using arrays it is possible to combine them with the `$types` parameter
531
+ * in order to define how to convert the values:
523
532
*
524
533
* {{{
525
- * // LEFT JOIN authors a ON posts.author_id = a.id
526
- * $query->leftJoin(['a' => 'authors'], ['posts.author_id = a.id']);
534
+ * $query->leftJoin(['a' => 'articles'], [
535
+ * 'a.posted >=' => new DateTime('-3 days'),
536
+ * 'a.published' => true,
537
+ * 'a.author_id = authors.id'
538
+ * ], ['a.posted' => 'datetime', 'a.published' => 'boolean']);
527
539
* }}}
528
540
*
541
+ * See `join()` for further details on conditions and types.
542
+ *
529
543
* @param string|array $table The table to join with
530
544
* @param string|array|\Cake\Database\ExpressionInterface $conditions The conditions
531
545
* to use for joining.
@@ -540,18 +554,10 @@ public function leftJoin($table, $conditions = [], $types = []) {
540
554
/**
541
555
* Adds a single RIGHT JOIN clause to the query.
542
556
*
543
- * {{{
544
- * // RIGHT JOIN authors ON posts.author_id = authors.id
545
- * $query->rightJoin('authors', ['posts.author_id = authors.id']);
546
- * }}}
547
- *
548
- * You can pass an array in the first parameter if you need to alias
549
- * the table for the join:
557
+ * This is a shorthand method for building joins via `join()`.
550
558
*
551
- * {{{
552
- * // RIGHT JOIN authors a ON posts.author_id = a.id
553
- * $query->righJoin(['a' => 'authors'], ['posts.author_id = a.id']);
554
- * }}}
559
+ * The arguments of this method are identical to the `leftJoin()` shorthand, please refer
560
+ * to that methods description for further details.
555
561
*
556
562
* @param string|array $table The table to join with
557
563
* @param string|array|\Cake\Database\ExpressionInterface $conditions The conditions
@@ -567,18 +573,10 @@ public function rightJoin($table, $conditions = [], $types = []) {
567
573
/**
568
574
* Adds a single INNER JOIN clause to the query.
569
575
*
570
- * {{{
571
- * // INNER JOIN authors ON posts.author_id = authors.id
572
- * $query->innerJoin('authors', ['posts.author_id = authors.id']);
573
- * }}}
576
+ * This is a shorthand method for building joins via `join()`.
574
577
*
575
- * You can pass an array in the first parameter if you need to alias
576
- * the table for the join:
577
- *
578
- * {{{
579
- * // INNER JOIN authors a ON posts.author_id = a.id
580
- * $query->innerJoin(['a' => 'authors'], ['posts.author_id = a.id']);
581
- * }}}
578
+ * The arguments of this method are identical to the `leftJoin()` shorthand, please refer
579
+ * to that methods description for further details.
582
580
*
583
581
* @param string|array $table The table to join with
584
582
* @param string|array|\Cake\Database\ExpressionInterface $conditions The conditions
0 commit comments