Merge pull request 'where should accept $relation as null' (#26) from bugfix/fix-where-closure into master
All checks were successful
soko-web/pipeline/head This commit looks good

Reviewed-on: #26
This commit is contained in:
Bence Pőcze 2023-07-08 14:38:40 +02:00
commit 8bf495c89b
Signed by: Gitea
GPG Key ID: 7B89B83EED9AD2C6

View File

@ -97,28 +97,28 @@ class Select
return $this; return $this;
} }
public function where($column, string $relation = null, $value = null): Select public function where($column, ?string $relation = null, $value = null): Select
{ {
$this->addWhereCondition('AND', $column, $relation, $value); $this->addWhereCondition('AND', $column, $relation, $value);
return $this; return $this;
} }
public function orWhere($column, string $relation = null, $value = null): Select public function orWhere($column, ?string $relation = null, $value = null): Select
{ {
$this->addWhereCondition('OR', $column, $relation, $value); $this->addWhereCondition('OR', $column, $relation, $value);
return $this; return $this;
} }
public function having($column, string $relation = null, $value = null): Select public function having($column, ?string $relation = null, $value = null): Select
{ {
$this->addHavingCondition('AND', $column, $relation, $value); $this->addHavingCondition('AND', $column, $relation, $value);
return $this; return $this;
} }
public function orHaving($column, string $relation = null, $value = null): Select public function orHaving($column, ?string $relation = null, $value = null): Select
{ {
$this->addHavingCondition('OR', $column, $relation, $value); $this->addHavingCondition('OR', $column, $relation, $value);
@ -211,12 +211,12 @@ class Select
$this->joins[] = [$type, $table, $column1, $relation, $column2]; $this->joins[] = [$type, $table, $column1, $relation, $column2];
} }
private function addWhereCondition(string $logic, $column, string $relation, $value): void private function addWhereCondition(string $logic, $column, ?string $relation, $value): void
{ {
$this->conditions[self::CONDITION_WHERE][] = [$logic, $column, $relation, $value]; $this->conditions[self::CONDITION_WHERE][] = [$logic, $column, $relation, $value];
} }
private function addHavingCondition(string $logic, $column, string $relation, $value): void private function addHavingCondition(string $logic, $column, ?string $relation, $value): void
{ {
$this->conditions[self::CONDITION_HAVING][] = [$logic, $column, $relation, $value]; $this->conditions[self::CONDITION_HAVING][] = [$logic, $column, $relation, $value];
} }