/** * Create the SQL of a function expression * @param zibo\library\database\manipulation\expression\FunctionExpression $function * @return string SQL of the function expression */ protected function parseFunctionExpression(FunctionExpression $function) { $sql = $function->getName() . '('; if ($function->isDistinct()) { $sql .= 'DISTINCT '; } $arguments = $function->getArguments(); if ($arguments) { $argumentSql = ''; foreach ($arguments as $expression) { $argumentSql .= ($argumentSql ? ', ' : '') . $this->parseExpression($expression); } $sql .= $argumentSql; } return $sql . ')'; }
/** * Processes the relations and the localization of the arguments used in a function expression * @param zibo\library\database\manipulation\expression\FunctionExpression $expression Function expression to process * @param boolean $inCondition Flag to see whether this expression is used in a condition or else where * @return zibo\library\database\manipulation\expression\FunctionExpression Processed function expression */ private function processFunctionExpression(FunctionExpression $expression, $inCondition) { $function = new FunctionExpression($expression->getName(), $expression->getAlias()); $function->setDistinct($expression->isDistinct()); $arguments = $expression->getArguments(); foreach ($arguments as $argument) { $argument = $this->processExpression($argument, $inCondition); $function->addArgument($argument); } return $function; }