/** * 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)); }
/** * @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)); }
/** * @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)); } }
/** * @covers ::__construct * @covers ::getColumn */ public function testConstruct() { $condition = new SQL\Condition('test1', '!= ?'); $this->assertEquals('test1', $condition->getColumn()); $this->assertEquals('!= ?', $condition->getContent()); }