コード例 #1
0
 public function testAssemble()
 {
     $clause = new OrderByClause();
     $clause->addField((new FieldExpression())->setField('first'));
     $this->assertEquals('ORDER BY first', QueryAssembler::stringify($clause));
     $clause->clearFields();
     $clause->addField((new FieldExpression())->setField('first'), 'ASC');
     $this->assertEquals('ORDER BY first ASC', QueryAssembler::stringify($clause));
     $clause->clearFields();
     $clause->addField((new FieldExpression())->setField('first'), 'DESC');
     $this->assertEquals('ORDER BY first DESC', QueryAssembler::stringify($clause));
     $clause->addField((new FieldExpression())->setField('second'), 'ASC');
     $this->assertEquals('ORDER BY first DESC, second ASC', QueryAssembler::stringify($clause));
     $clause->addField('third', 'DESC');
     $this->assertEquals('ORDER BY first DESC, second ASC, third DESC', QueryAssembler::stringify($clause));
     $clause->addField(CustomSelectExpression::create('DATE(`test`)'));
     $this->assertEquals('ORDER BY first DESC, second ASC, third DESC, DATE(`test`)', QueryAssembler::stringify($clause));
 }
コード例 #2
0
 public function assembleCustomSelect(CustomSelectExpression $expr)
 {
     return $this->assembleSegment($expr->getField()) . ($expr->hasAlias() ? ' AS ' . $this->escapeField($expr->getAlias()) : '');
 }
コード例 #3
0
 public function testCustomSelectExpression()
 {
     $this->assertEquals('MY_CUSTOM_FUNCTION(doodads,foobar) AS custom', QueryAssembler::stringify(CustomSelectExpression::createWithAlias('MY_CUSTOM_FUNCTION(doodads,foobar)', 'custom')));
 }