Beispiel #1
0
 /**
  * Render a Condition object
  *
  * @param  SQL\Condition $condition
  * @return string
  */
 public static function render(SQL\Condition $condition)
 {
     $content = $condition->getContent();
     $parameters = $condition->getParameters();
     if ($parameters and is_string($content)) {
         $content = self::expandParameterArrays($content, $parameters);
     }
     return Compiler::expression(array(Compiler::name($condition->getColumn()), $content));
 }
Beispiel #2
0
 /**
  * @param  array  $condition
  * @return string
  */
 public static function renderArrayCondition(array $condition)
 {
     $statements = array();
     foreach ($condition as $column => $foreignColumn) {
         $link = $foreignColumn instanceof SQL\SQL ? $foreignColumn : '= ' . Compiler::name($foreignColumn);
         $statements[] = Compiler::name($column) . ' ' . $link;
     }
     return 'ON ' . join(' AND ', $statements);
 }
Beispiel #3
0
 /**
  * Render SQL for Aliased
  *
  * @param  SQL\Aliased $aliased
  * @return string
  */
 public static function render(SQL\Aliased $aliased)
 {
     $content = $aliased->getContent();
     if ($content instanceof Query\Select) {
         $content = "(" . Select::render($content) . ")";
     } else {
         $content = Compiler::name($content);
     }
     return Compiler::expression(array($content, Compiler::word('AS', Compiler::name($aliased->getAlias()))));
 }
Beispiel #4
0
 /**
  * @covers ::name
  * @covers ::escapeName
  */
 public function testName()
 {
     $db1 = self::getNewDb()->setEscaping(DB::ESCAPING_STANDARD);
     $this->assertEquals('test1', Compiler::name('test1'));
     $this->assertEquals(new SQL('Test'), Compiler::name(new SQL('Test')));
     $this->assertEquals('test1.name', Compiler::name('test1.name'));
     $self = $this;
     Compiler::withDb($db1, function () use($self) {
         $self->assertEquals('"test1"', Compiler::name('test1'));
         $self->assertEquals('"test1"."name"', Compiler::name('test1.name'));
     });
 }
Beispiel #5
0
 /**
  * Render a Direction object
  *
  * @param  SQL\Direction $item
  * @return string
  */
 public static function render(SQL\Direction $item)
 {
     return Compiler::expression(array(Compiler::name($item->getContent()), $item->getDirection()));
 }
Beispiel #6
0
 /**
  * Render a Set object
  * @param  SQL\Set $item
  * @return string
  */
 public static function render(SQL\Set $item)
 {
     return Compiler::expression(array(Compiler::name($item->getContent()), '=', self::renderValue($item)));
 }