web-base/Core/Driver/SQL/Expression/NullIf.class.php

22 lines
454 B
PHP
Raw Permalink Normal View History

2023-01-11 15:28:47 +01:00
<?php
namespace Core\Driver\SQL\Expression;
use Core\Driver\SQL\SQL;
class NullIf extends Expression {
private mixed $lhs;
private mixed $rhs;
public function __construct(mixed $lhs, mixed $rhs) {
$this->lhs = $lhs;
$this->rhs = $rhs;
}
function getExpression(SQL $sql, array &$params): string {
$lhs = $sql->addValue($this->lhs, $params);
$rhs = $sql->addValue($this->rhs, $params);
return "NULLIF($lhs, $rhs)";
}
}