New Sql operators, because they may come in handy

This commit is contained in:
Marcin Kurczewski 2014-02-24 00:15:38 +01:00
parent ae09f20910
commit b144321c76
2 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,17 @@
<?php
class SqlIfNullOperator extends SqlOperator
{
protected $subject;
protected $target;
public function __construct($subject, $target)
{
$this->subject = $this->attachExpression($subject);
$this->target = $this->attachExpression($target);
}
public function getAsString()
{
return 'IFNULL (' . $this->subject->getAsString() . ', ' . $this->target->getAsString() . ')';
}
}

View file

@ -0,0 +1,8 @@
<?php
class SqlMaxOperator extends SqlUnaryOperator
{
public function getAsStringNonEmpty()
{
return 'MAX (' . $this->subject->getAsString() . ')';
}
}