public function addField($field, $alias = null) { if ($field instanceof ISelectExpression) { $this->addExpression($field); } else { if (is_scalar($field)) { $this->addExpression(FieldSelectExpression::create($field, $alias)); } else { if (is_array($field)) { foreach ($field as $fName => $values) { $expr = new ConcatSelectExpression(); $expr->setPropertyArray($values); $expr->setAlias($fName); $this->addExpression($expr); } } else { throw new \InvalidArgumentException("Invalid field type entered"); } } } return $this; }
public function assembleConcatSelectExpression(ConcatSelectExpression $expr) { return 'CONCAT(' . implode(',', $this->assembleSegments($expr->getProperties())) . ')' . ($expr->hasAlias() ? ' AS ' . $this->escapeField($expr->getAlias()) : ''); }
public function testStatics() { $this->assertEquals('CONCAT(one,two)', QueryAssembler::stringify(ConcatSelectExpression::create('one', 'two'))); $this->assertEquals('CONCAT(one,\'-\',two)', QueryAssembler::stringify(ConcatSelectExpression::create('one', "'-'", 'two'))); }