public function testStatics() { $this->assertEquals('SUBSTRING(fieldname,0)', QueryAssembler::stringify(SubStringSelectExpression::create('fieldname'))); $this->assertEquals('SUBSTRING(fieldname,0) AS new', QueryAssembler::stringify(SubStringSelectExpression::createWithAlias('fieldname', 'new'))); $this->assertEquals('SUBSTRING(fieldname,10) AS new', QueryAssembler::stringify(SubStringSelectExpression::create('fieldname', 10, null, 'new'))); $this->assertEquals('SUBSTRING(fieldname,10,5) AS new', QueryAssembler::stringify(SubStringSelectExpression::create('fieldname', 10, 5, 'new'))); }
public function assembleSubStringSelectExpression(SubStringSelectExpression $expr) { return $expr->getFunctionName() . '(' . $this->getAssembler()->assembleSegment($expr->getField()) . ',' . $expr->getStartPosition() . ($expr->hasLength() ? ',' . $expr->getLength() : '') . ')' . ($expr->hasAlias() ? ' AS ' . $this->escapeField($expr->getAlias()) : ''); }