public function testGetTable() { $statement = new FinalTableTrait(); $statement->setTable(null); $this->assertNull($statement->getTable()); $table = TableSelectExpression::create('table_one'); $table->setAlias('t1'); $statement = new FinalTableTrait(); $statement->setTable($table); $this->assertInstanceOf(TableExpression::class, $statement->getTable()); }
public function testAssemble() { $sel1 = TableSelectExpression::create('table_one'); $this->assertEquals('`table_one`', MySQLAssembler::stringify($sel1)); $sel1->setAlias('t1'); $this->assertEquals('`table_one` AS `t1`', MySQLAssembler::stringify($sel1)); $sel2 = new TableSelectExpression(); $sel2->setTable('table_two'); $this->assertEquals('table_two', QueryAssembler::stringify($sel2)); $sel2->setAlias('t2'); $this->assertEquals('table_two AS t2', QueryAssembler::stringify($sel2)); $sel3 = TableSelectExpression::createWithAlias(TableExpression::create('table_three'), 't3'); $this->assertEquals('`table_three` AS `t3`', MySQLAssembler::stringify($sel3)); }
public function assembleTable(TableSelectExpression $field) { return $this->assembleSegment($field->getTable()) . ($field->hasAlias() ? ' AS ' . $this->escapeField($field->getAlias()) : ''); }
public function testLeftFullStmt() { $query = QueryBuilder::select(AllSelectExpression::create())->from(TableSelectExpression::createWithAlias('table_one', 't1'))->leftOuterJoin(TableSelectExpression::create('table_two'), 'myfield'); $this->assertEquals('SELECT * FROM table_one AS t1 LEFT OUTER JOIN table_two ON t1.myfield = table_two.myfield', QueryAssembler::stringify($query)); }