Skip to content

Commit 502338b

Browse files
committed
Add IN statement
1 parent f7d9eb4 commit 502338b

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/QueryBuilder/QueryBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function __toString(): string
3838
$request = str_replace('[TABLE_NAME]', $this->table, $this->action);
3939

4040
if (!is_null($this->condition)) $request .= $this->condition;
41+
if (!is_null($this->in)) $request .= $this->in;
4142
if (!is_null($this->orderBy)) $request .= $this->orderBy;
4243
if (!is_null($this->limit)) $request .= $this->limit;
4344

src/QueryBuilder/QueryMethods.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ trait QueryMethods
1111
protected array $values = [];
1212
protected ?string $orderBy = null;
1313
protected ?string $limit = null;
14+
protected ?string $in = null;
1415

1516
public function table(string $table): self
1617
{
@@ -143,4 +144,17 @@ public function limit(int $limit, int $offset = 0): self
143144
$this->limit = " LIMIT $limit OFFSET $offset";
144145
return $this;
145146
}
147+
148+
/**
149+
* in
150+
*
151+
* @param array $in
152+
* @return self
153+
*/
154+
public function in(array $in): self
155+
{
156+
$in = implode(',', $in);
157+
$this->in = " IN($in)";
158+
return $this;
159+
}
146160
}

0 commit comments

Comments
 (0)