Skip to content

Commit

Permalink
Fix join docblocks.
Browse files Browse the repository at this point in the history
Corrects syntax errors and changes the examples to match the
description and the actually generated SQL.
  • Loading branch information
ndm2 committed Dec 20, 2014
1 parent 610c59e commit 4150f29
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/Database/Query.php
Expand Up @@ -396,10 +396,10 @@ public function from($tables = [], $overwrite = false) {
* to be joined, unless the third argument is set to true.
*
* When no join type is specified an INNER JOIN is used by default:
* ``$query->join(['authors'])`` Will produce INNER JOIN authors ON (1 = 1)
* ``$query->join(['authors'])`` Will produce ``INNER JOIN authors ON 1 = 1``
*
* It is also possible to alias joins using the array key:
* ``$query->join(['a' => 'authors'])`` Will produce INNER JOIN authors a ON (1 = 1)
* ``$query->join(['a' => 'authors'])`` Will produce ``INNER JOIN authors a ON 1 = 1``
*
* A join can be fully described and aliased using the array notation:
*
Expand All @@ -411,7 +411,7 @@ public function from($tables = [], $overwrite = false) {
* 'conditions' => 'a.id = b.author_id'
* ]
* ]);
* // Produces LEFT JOIN authors a ON (a.id = b.author_id)
* // Produces LEFT JOIN authors a ON a.id = b.author_id
* }}}
*
* You can even specify multiple joins in an array, including the full description:
Expand All @@ -424,13 +424,13 @@ public function from($tables = [], $overwrite = false) {
* 'conditions' => 'a.id = b.author_id'
* ],
* 'p' => [
* 'table' => 'products',
* 'table' => 'publishers',
* 'type' => 'INNER',
* 'conditions' => 'a.owner_id = p.id
* 'conditions' => 'b.publisher_id = p.id AND p.name = "Cake Software Foundation"'
* ]
* ]);
* // LEFT JOIN authors a ON (a.id = b.author_id)
* // INNER JOIN products p (a.owner_id = p.id)
* // LEFT JOIN authors a ON a.id = b.author_id
* // INNER JOIN publishers p ON b.publisher_id = p.id AND p.name = "Cake Software Foundation"
* }}}
*
* ### Using conditions and types
Expand All @@ -448,7 +448,7 @@ public function from($tables = [], $overwrite = false) {
* 'table' => 'articles',
* 'conditions' => [
* 'a.posted >=' => new DateTime('-3 days'),
* 'a.published' => true
* 'a.published' => true,
* 'a.author_id = authors.id'
* ]
* ]], ['a.posted' => 'datetime', 'a.published' => 'boolean'])
Expand Down Expand Up @@ -514,16 +514,16 @@ public function join($tables = null, $types = [], $overwrite = false) {
* Adds a single LEFT JOIN clause to the query.
*
* {{{
* // LEFT JOIN authors ON posts.author_id' = authors.id
* $query->leftJoin('authors', ['posts.author_id' = authors.id']);
* // LEFT JOIN authors ON posts.author_id = authors.id
* $query->leftJoin('authors', ['posts.author_id = authors.id']);
* }}}
*
* You can pass an array in the first parameter if you need to alias
* the table for the join:
*
* {{{
* // LEFT JOIN authors a ON posts.author_id' = a.id
* $query->leftJoin(['a' => 'authors'], ['posts.author_id' = 'a.id']);
* // LEFT JOIN authors a ON posts.author_id = a.id
* $query->leftJoin(['a' => 'authors'], ['posts.author_id = a.id']);
* }}}
*
* @param string|array $table The table to join with
Expand All @@ -541,16 +541,16 @@ public function leftJoin($table, $conditions = [], $types = []) {
* Adds a single RIGHT JOIN clause to the query.
*
* {{{
* // RIGHT JOIN authors ON posts.author_id' = authors.id
* $query->rightJoin('authors', ['posts.author_id' = authors.id']);
* // RIGHT JOIN authors ON posts.author_id = authors.id
* $query->rightJoin('authors', ['posts.author_id = authors.id']);
* }}}
*
* You can pass an array in the first parameter if you need to alias
* the table for the join:
*
* {{{
* // RIGHT JOIN authors a ON posts.author_id' = a.id
* $query->righJoin(['a' => 'authors'], ['posts.author_id' = 'a.id']);
* // RIGHT JOIN authors a ON posts.author_id = a.id
* $query->righJoin(['a' => 'authors'], ['posts.author_id = a.id']);
* }}}
*
* @param string|array $table The table to join with
Expand All @@ -568,16 +568,16 @@ public function rightJoin($table, $conditions = [], $types = []) {
* Adds a single INNER JOIN clause to the query.
*
* {{{
* // INNER JOIN authors ON posts.author_id' = authors.id
* $query->innerJoin('authors', ['posts.author_id' = authors.id']);
* // INNER JOIN authors ON posts.author_id = authors.id
* $query->innerJoin('authors', ['posts.author_id = authors.id']);
* }}}
*
* You can pass an array in the first parameter if you need to alias
* the table for the join:
*
* {{{
* // INNER JOIN authors a ON posts.author_id' = a.id
* $query->innerJoin(['a' => 'authors'], ['posts.author_id' = 'a.id']);
* // INNER JOIN authors a ON posts.author_id = a.id
* $query->innerJoin(['a' => 'authors'], ['posts.author_id = a.id']);
* }}}
*
* @param string|array $table The table to join with
Expand Down

0 comments on commit 4150f29

Please sign in to comment.