Skip to content

Commit

Permalink
Implemented get parameters method for update queries
Browse files Browse the repository at this point in the history
  • Loading branch information
PeeHaa committed Apr 27, 2019
1 parent cd8907d commit d3287c6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/QueryBuilder/Statement/Set.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ public function toSql(): string
{
return $this->condition->toSql();
}

/**
* @return mixed[]
*/
public function getParameters(): array
{
return $this->condition->getParameters();
}
}
26 changes: 26 additions & 0 deletions src/QueryBuilder/Statement/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,30 @@ public function getQuery(): string

return 'UPDATE ' . $this->table->toSql() . $set . $joins . $condition . $orders . $limit . $offset;
}

/**
* @return mixed[]
*/
public function getParameters(): array
{
$parameters = [];

if ($this->set) {
foreach ($this->set as $set) {
$parameters = array_merge($parameters, $set->getParameters());
}
}

if ($this->joins) {
foreach ($this->joins as $join) {
$parameters = array_merge($parameters, $join->getParameters());
}
}

if ($this->condition !== null) {
$parameters = array_merge($parameters, $this->condition->getParameters());
}

return $parameters;
}
}

0 comments on commit d3287c6

Please sign in to comment.