New Sql operators, because they may come in handy
This commit is contained in:
parent
ae09f20910
commit
b144321c76
2 changed files with 25 additions and 0 deletions
17
src/Sql/Operators/MiscOperators/SqlIfNullOperator.php
Normal file
17
src/Sql/Operators/MiscOperators/SqlIfNullOperator.php
Normal 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() . ')';
|
||||
}
|
||||
}
|
8
src/Sql/Operators/UnaryOperators/SqlMaxOperator.php
Normal file
8
src/Sql/Operators/UnaryOperators/SqlMaxOperator.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
class SqlMaxOperator extends SqlUnaryOperator
|
||||
{
|
||||
public function getAsStringNonEmpty()
|
||||
{
|
||||
return 'MAX (' . $this->subject->getAsString() . ')';
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue