Skip to content

Commit

Permalink
Improved getting the sql for functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosprotung committed Dec 15, 2016
1 parent 065686e commit 9ef9003
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,12 @@ public function getSql(SqlWalker $sqlWalker)
{
$this->validatePlatform($sqlWalker->getConnection()->getDatabasePlatform());

$result = sprintf('%s(', $this->functionName);

for ($i = 0, $size = count($this->geomExpr); $i < $size;) {
$result .= $this->geomExpr[$i]->dispatch($sqlWalker);

if (++$i < $size) {
$result .= ', ';
}
$arguments = array();
foreach ($this->geomExpr as $expression) {
$arguments[] = $expression->dispatch($sqlWalker);
}

$result .= ')';

return $result;
return sprintf('%s(%s)', $this->functionName, implode(', ', $arguments));
}

/**
Expand All @@ -118,8 +111,10 @@ protected function validatePlatform(AbstractPlatform $platform)
{
$platformName = $platform->getName();

if (isset($this->platforms) && ! in_array($platformName, $this->platforms)) {
throw new UnsupportedPlatformException(sprintf('DBAL platform "%s" is not currently supported.', $platformName));
if (isset($this->platforms) && !in_array($platformName, $this->platforms)) {
throw new UnsupportedPlatformException(
sprintf('DBAL platform "%s" is not currently supported.', $platformName)
);
}
}
}

0 comments on commit 9ef9003

Please sign in to comment.