public function getSql(SqlWalker $sqlWalker) { $args = array_map(function ($value) use($sqlWalker) { return $sqlWalker->walkArithmeticPrimary($value); }, $this->values); return 'GREATEST(' . implode(', ', $args) . ')'; }
/** * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker * * @return string */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { // use second parameter if parsed if (null !== $this->fmt) { return sprintf('TRUNC(%s, %s)', $sqlWalker->walkArithmeticPrimary($this->date), $sqlWalker->walkArithmeticPrimary($this->fmt)); } return sprintf('TRUNC(%s)', $sqlWalker->walkArithmeticPrimary($this->date)); }
/** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); if (!method_exists($platform, 'getStringAgg')) { return $sqlWalker->walkStringPrimary($this->firstStringPrimary); } return $platform->getStringAgg($sqlWalker->walkStringPrimary($this->firstStringPrimary), $sqlWalker->walkStringPrimary($this->secondStringPrimary)); }
/** * {@inheritdoc} */ public function getSql(SqlWalker $sqlWalker) { $stringPrimary = $sqlWalker->walkStringPrimary($this->stringPrimary); $platform = $sqlWalker->getConnection()->getDatabasePlatform(); $trimMode = $this->getTrimMode(); $trimChar = $this->trimChar !== false ? $sqlWalker->getConnection()->quote($this->trimChar) : false; return $platform->getTrimExpression($stringPrimary, $trimMode, $trimChar); }
public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $secondArgument = ''; if ($this->optionalSecondExpression) { $secondArgument = $sqlWalker->walkSimpleArithmeticExpression($this->optionalSecondExpression); } return 'ATAN(' . $sqlWalker->walkSimpleArithmeticExpression($this->arithmeticExpression) . ($secondArgument ? ', ' . $secondArgument : '') . ')'; }
public function getSql(SqlWalker $sqlWalker) { $args = array_map(function ($value) use($sqlWalker) { $nodeSql = $sqlWalker->walkArithmeticPrimary($value); return $this->notEmpty ? sprintf("NULLIF(%s, '')", $nodeSql) : $nodeSql; }, $this->values); return 'CONCAT_WS(' . implode(', ', $args) . ')'; }
/** * @param SqlWalker $sqlWalker * @return string */ public function getSql(SqlWalker $sqlWalker) { $args = array(); foreach ($this->concatExpressions as $expression) { $args[] = $sqlWalker->walkStringPrimary($expression); } return 'CONCAT_WS(' . join(', ', (array) $args) . ')'; }
/** * @param SqlWalker $sqlWalker * * @return string */ public function getSql(SqlWalker $sqlWalker) { $this->validatePlatform($sqlWalker->getConnection()->getDatabasePlatform()); if ($this->optionalExpression) { return sprintf('%s(%s, %s, %s)', $this->functionName, $this->firstGeomExpression->dispatch($sqlWalker), $this->secondGeomExpression->dispatch($sqlWalker), $this->optionalExpression->dispatch($sqlWalker)); } return sprintf('%s(%s, %s)', $this->functionName, $this->firstGeomExpression->dispatch($sqlWalker), $this->secondGeomExpression->dispatch($sqlWalker)); }
/** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); $strings = array_map(function ($v) use($sqlWalker) { return $sqlWalker->walkStringPrimary($v); }, $this->strings); return call_user_func_array(array($platform, 'getConcatExpression'), $strings); }
/** * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker * @return string */ public function getSql(SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); if ($platform instanceof PostgreSqlPlatform) { return $this->getPostgreSql($sqlWalker); } throw new NotImplementedException(); }
/** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $optionalSecondSimpleArithmeticExpression = null; if ($this->secondSimpleArithmeticExpression !== null) { $optionalSecondSimpleArithmeticExpression = $sqlWalker->walkSimpleArithmeticExpression($this->secondSimpleArithmeticExpression); } return $sqlWalker->getConnection()->getDatabasePlatform()->getSubstringExpression($sqlWalker->walkStringPrimary($this->stringPrimary), $sqlWalker->walkSimpleArithmeticExpression($this->firstSimpleArithmeticExpression), $optionalSecondSimpleArithmeticExpression); }
/** * {@inheritdoc} */ public function getSql(SqlWalker $sqlWalker) { $strings = array(); $stringExpressions = $this->parameters[Base::STRINGS_KEY]; foreach ($stringExpressions as $stringExp) { $strings[] = $sqlWalker->walkStringPrimary($stringExp); } return sprintf('CONCAT_WS(%s, %s)', $sqlWalker->walkStringPrimary($this->parameters[Base::SEPARATOR_KEY]), implode(', ', $strings)); }
/** * {@inheritdoc} */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $strings = array(); $stringExpressions = $this->parameters['strings']; foreach ($stringExpressions as $stringExp) { $strings[] = $sqlWalker->walkStringPrimary($stringExp); } return sprintf('CONCAT_WS(%s, %s)', $sqlWalker->walkStringPrimary($this->parameters['separator']), implode(', ', $strings)); }
/** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { //TODO: Use platform to get SQL $sql = 'LOCATE(' . $sqlWalker->walkStringPrimary($this->_firstStringPrimary) . ', ' . $sqlWalker->walkStringPrimary($this->_secondStringPrimary); if ($this->_simpleArithmeticExpression) { $sql .= ', ' . $sqlWalker->walkSimpleArithmeticExpression($this->_simpleArithmeticExpression); } return $sql . ')'; }
/** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $sql = "WEEK(" . $sqlWalker->walkArithmeticPrimary($this->date); if ($this->mode != null) { $sql .= ", " . $sqlWalker->walkLiteral($this->mode); } $sql .= ")"; return $sql; }
/** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); $args = array(); foreach ($this->concatExpressions as $expression) { $args[] = $sqlWalker->walkStringPrimary($expression); } return call_user_func_array(array($platform, 'getConcatExpression'), $args); }
public function getSql(SqlWalker $sqlWalker) { $driver = $sqlWalker->getConnection()->getDriver()->getName(); if ($driver == 'pdo_sqlite') { return sprintf("CAST(STRFTIME('%s', %s) AS INTEGER)", $this->formats[$this->field], $this->source->dispatch($sqlWalker)); } else { return sprintf('EXTRACT(%s FROM %s %s)', $this->field, (string) $this->type, $this->source->dispatch($sqlWalker)); } }
/** * @param SqlWalker $sqlWalker * * @return string */ public function getSql(SqlWalker $sqlWalker) { $this->validatePlatform($sqlWalker->getConnection()->getDatabasePlatform()); $result = sprintf('%s(%s', $this->functionName, $this->geomExpr[0]->dispatch($sqlWalker)); for ($i = 1, $size = count($this->geomExpr); $i < $size; $i++) { $result .= ', ' . $this->geomExpr[$i]->dispatch($sqlWalker); } $result .= ')'; return $result; }
/** * @param \Doctrine\ORM\Query\AST\Node $AST * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker */ public function __construct(AST\Node $AST, $sqlWalker) { if ($AST instanceof AST\UpdateStatement) { $this->_sqlStatements = $sqlWalker->walkUpdateStatement($AST); } else { if ($AST instanceof AST\DeleteStatement) { $this->_sqlStatements = $sqlWalker->walkDeleteStatement($AST); } } }
/** * {@inheritdoc} */ public function getSql(SqlWalker $sqlWalker) { // This type is defined by ANSI SQL $targetType = 'VARCHAR'; // MySQL needs a CHAR type for string conversion (http://dev.mysql.com/doc/refman/5.7/en/type-conversion.html) if ($sqlWalker->getConnection()->getDatabasePlatform()->getName() === 'mysql') { $targetType = 'CHAR'; } return 'CAST(' . $sqlWalker->walkSimpleArithmeticExpression($this->stringPrimary) . ' AS ' . $targetType . ')'; }
/** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $dqlAlias = $this->pathExpression->identificationVariable; $assocField = $this->pathExpression->field; $qComp = $sqlWalker->getQueryComponent($dqlAlias); $class = $qComp['metadata']; $assoc = $class->associationMappings[$assocField]; $tableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); return $tableAlias . '.' . reset($assoc['targetToSourceKeyColumns']); }
/** * {@inheritdoc} */ public function getSql(SqlWalker $s) { $platform = $s->getConnection()->getDatabasePlatform()->getName(); switch ($platform) { case 'postgresql': return sprintf('ST_Distance_Sphere(%s, %s)', $this->arg1->dispatch($s), $this->arg2->dispatch($s)); case 'sqlite': return sprintf('GreatCircleLength(MakeLine(%s, %s))', $this->arg1->dispatch($s), $this->arg2->dispatch($s)); } return sprintf(self::FORMULA, self::EARTH_RADIUS, $this->y($this->arg1->dispatch($s)), $this->y($this->arg2->dispatch($s)), $this->y($this->arg1->dispatch($s)), $this->y($this->arg2->dispatch($s)), $this->x($this->arg2->dispatch($s)), $this->x($this->arg1->dispatch($s))); }
/** * @param SqlWalker $sqlWalker * @return string */ public function getSql(SqlWalker $sqlWalker) { $driver = $sqlWalker->getConnection()->getDriver()->getName(); $translationField = $this->stringField->dispatch($sqlWalker); $translationsAlias = explode('.', $translationField)[0]; $query = $translationField; if ($driver == 'pdo_pgsql') { $query = "string_agg(DISTINCT " . $translationField . "|| ' [' || " . $translationsAlias . ".locale || '] ', '<br>')"; } return $query; }
/** * @override */ public function getSql(SqlWalker $sqlWalker) { switch (strtolower($this->unit->value)) { case 'day': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression($this->firstDateExpression->dispatch($sqlWalker), $this->intervalExpression->dispatch($sqlWalker)); case 'month': return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression($this->firstDateExpression->dispatch($sqlWalker), $this->intervalExpression->dispatch($sqlWalker)); default: throw QueryException::semanticalError('DATE_ADD() only supports units of type day and month.'); } }
/** * @param SqlWalker $sqlWalker * @return string * @throws QueryException */ public function getSql(SqlWalker $sqlWalker) { switch ($sqlWalker->getConnection()->getDatabasePlatform()->getName()) { case 'postgresql': return 'RANDOM()'; case 'mysql': return 'RAND()'; default: throw new QueryException("You can't use RANDOM()!"); } }
/** * {@inheritdoc} */ public function getSql(SqlWalker $sqlWalker) { $dqlAlias = $this->pathExpression->identificationVariable; $qComp = $sqlWalker->getQueryComponent($dqlAlias); $class = $qComp['metadata']; $tableAlias = $sqlWalker->getSQLTableAlias($class->getTableName(), $dqlAlias); if (is_array($class->discriminatorColumn) && isset($class->discriminatorColumn['name'])) { return $tableAlias . '.' . $class->discriminatorColumn['name']; } else { return ''; } }
/** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $platform = $sqlWalker->getConnection()->getDatabasePlatform(); return $platform->getConcatExpression($sqlWalker->walkStringPrimary($this->_firstStringPrimary), $sqlWalker->walkStringPrimary($this->_secondStringPrimary)); /* $sql = 'CONCAT(' . $sqlWalker->walkStringPrimary($this->_firstStringPrimary) . ', ' . $sqlWalker->walkStringPrimary($this->_secondStringPrimary) . ')'; return $sql;*/ }
/** * @param SqlWalker $sqlWalker */ protected function loadConversionHints(SqlWalker $sqlWalker) { /* @var SqlConversionInfo|\Closure $hintsValue */ if (!($hintsValue = $sqlWalker->getQuery()->getHint('rws_conversion_hint'))) { throw new \LogicException('Missing "rws_conversion_hint" hint for ' . get_class($this)); } if ($hintsValue instanceof SqlConversionInfo) { $this->nativePlatform = $hintsValue->nativePlatform; $this->parameters = $hintsValue->parameters; } else { list($this->nativePlatform, $this->parameters) = $hintsValue(); } }
public function getSql(SqlWalker $sqlWalker) { $unit = strtolower($this->unit); if ($unit == "day") { return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddDaysExpression($this->firstDateExpression->dispatch($sqlWalker), $this->intervalExpression->dispatch($sqlWalker)); } else { if ($unit == "month") { return $sqlWalker->getConnection()->getDatabasePlatform()->getDateAddMonthExpression($this->firstDateExpression->dispatch($sqlWalker), $this->intervalExpression->dispatch($sqlWalker)); } else { throw QueryException::semanticalError('DATE_ADD() only supports units of type day and month.'); } } }
/** * @param SqlWalker $sqlWalker * * @return string */ 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 .= ', '; } } $result .= ')'; return $result; }