Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Commit 0f64c16

Browse files
author
Daniel Opitz
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/Database/SelectQuery.php
2 parents 1de43cb + 754cc3c commit 0f64c16

3 files changed

Lines changed: 10 additions & 12 deletions

File tree

docs/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,13 +242,13 @@ Please use the [join](#inner-join-clause) method.
242242
#### Advanced Join Clauses
243243

244244
You may also specify more advanced join clauses.
245-
To get started, pass a RawExp as the second argument into
245+
To get started, pass a (raw) string as the second argument into
246246
the `joinRaw` and `leftJoinRaw` method.
247247

248248
```php
249249
$users = $this->select()
250250
->from('users AS u')
251-
->joinRaw('posts AS p', new RawExp('p.user_id=u.id AND u.enabled=1 OR p.published IS NULL'))
251+
->joinRaw('posts AS p', 'p.user_id=u.id AND u.enabled=1 OR p.published IS NULL')
252252
->execute()
253253
->fetchAll();
254254
```

src/Database/SelectQuery.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,12 @@ public function leftJoin(string $table, string $leftField, string $comparison, $
230230
* Join with complex conditions.
231231
*
232232
* @param string $table Table name
233-
* @param RawExp $raw
234-
*
233+
* @param string $conditions The ON conditions e.g. 'user.id = article.user_id'
235234
* @return self
236235
*/
237-
public function joinRaw(string $table, RawExp $raw): self
236+
public function joinRaw(string $table, string $conditions): self
238237
{
239-
$this->join[] = ['inner', $table, $raw, null, null, null];
238+
$this->join[] = ['inner', $table, new RawExp($conditions), null, null, null];
240239

241240
return $this;
242241
}
@@ -245,13 +244,12 @@ public function joinRaw(string $table, RawExp $raw): self
245244
* Left join with complex conditions.
246245
*
247246
* @param string $table Table name
248-
* @param RawExp $raw
249-
*
247+
* @param string $conditions The ON conditions e.g. 'user.id = article.user_id'
250248
* @return self
251249
*/
252-
public function leftJoinRaw(string $table, RawExp $raw): self
250+
public function leftJoinRaw(string $table, string $conditions): self
253251
{
254-
$this->join[] = ['left', $table, $raw, null, null, null];
252+
$this->join[] = ['left', $table, new RawExp($conditions), null, null, null];
255253

256254
return $this;
257255
}

tests/SelectQueryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ public function testJoinRaw()
592592
$select = $this->select()
593593
->columns('id')
594594
->from('test')
595-
->joinRaw('users u', new RawExp('t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c OR t2.b IS NULL'));
595+
->joinRaw('users u', 't2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c OR t2.b IS NULL');
596596
$this->assertInstanceOf(PDOStatement::class, $select->prepare());
597597
$this->assertSame("SELECT `id` FROM `test` INNER JOIN `users` `u` ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c OR t2.b IS NULL);", $select->build());
598598
}
@@ -611,7 +611,7 @@ public function testLeftJoinRaw()
611611
$select = $this->select()
612612
->columns('id')
613613
->from('test')
614-
->leftJoinRaw('users u', new RawExp('t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c OR t2.b IS NULL'));
614+
->leftJoinRaw('users u', 't2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c OR t2.b IS NULL');
615615
$this->assertInstanceOf(PDOStatement::class, $select->prepare());
616616
$this->assertSame("SELECT `id` FROM `test` LEFT JOIN `users` `u` ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c OR t2.b IS NULL);", $select->build());
617617
}

0 commit comments

Comments
 (0)