Skip to content

Commit

Permalink
Enhance the possibilities for subclasses of the Where Clause Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
cundd committed Nov 27, 2018
1 parent 04b5ef5 commit 58997ae
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Classes/VirtualObject/Persistence/Backend/WhereClause.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public function getBoundVariables()
}

/**
* Bind the variable to the SQL WHERE-clause
*
* @param string $key
* @param string|int|float $value
* @return $this
Expand Down
36 changes: 32 additions & 4 deletions Classes/VirtualObject/Persistence/Backend/WhereClauseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ public function addConstraint(
}

$bindingKey = $bindingPrefix . $column;
$this->where->appendSql(
$this->appendSql(
$escapeColumnName($column)
. ' ' . $operator . ' '
. ':' . $bindingKey . '',
$combinator
);
$this->where->bindVariable(
$this->bindVariable(
$bindingKey,
$prepareValue($comparisonValue)
);
Expand Down Expand Up @@ -240,10 +240,38 @@ public static function resolveOperator($operator)
}
}

/**
* Append the string to the SQL WHERE-clause
*
* @param string $clause
* @param string $combinator
* @return $this
*/
protected function appendSql($clause, $combinator = QueryInterface::COMBINATOR_AND)
{
$this->where->appendSql($clause, $combinator);

return $this;
}

/**
* Bind the variable to the SQL WHERE-clause
*
* @param string $key
* @param string|int|float $value
* @return $this
*/
protected function bindVariable($key, $value)
{
$this->where->bindVariable($key, $value);

return $this;
}

/**
* @return \Closure
*/
private function getDefaultPrepareValueCallback()
protected function getDefaultPrepareValueCallback()
{
return function ($queryValue) {
return $queryValue;
Expand All @@ -253,7 +281,7 @@ private function getDefaultPrepareValueCallback()
/**
* @return \Closure
*/
private function getDefaultEscapeColumnNameCallback()
protected function getDefaultEscapeColumnNameCallback()
{
return function ($propertyName) {
return '`' . $propertyName . '`';
Expand Down

0 comments on commit 58997ae

Please sign in to comment.