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 string $column
  * @param array  $value
  */
 public function __construct($column, array $value)
 {
     if (empty($value)) {
         throw new InvalidArgumentException('Values must not be empty array');
     }
     parent::__construct($column, "IN ?", array($value));
 }
Beispiel #3
0
 /**
  * @param string $column
  * @param mixed  $value
  */
 public function __construct($column, $value)
 {
     if (is_array($value)) {
         throw new InvalidArgumentException('Use ConditionIn for array conditions');
     }
     if ($value === null) {
         parent::__construct($column, "IS NULL");
     } else {
         parent::__construct($column, "= ?", array($value));
     }
 }
Beispiel #4
0
 /**
  * @covers ::__construct
  * @covers ::getColumn
  */
 public function testConstruct()
 {
     $condition = new SQL\Condition('test1', '!= ?');
     $this->assertEquals('test1', $condition->getColumn());
     $this->assertEquals('!= ?', $condition->getContent());
 }