web-base/Core/Driver/SQL/Condition/CondKeyword.class.php

29 lines
869 B
PHP
Raw Normal View History

2020-06-19 14:12:07 +02:00
<?php
2022-11-18 18:06:46 +01:00
namespace Core\Driver\SQL\Condition;
2020-06-19 14:12:07 +02:00
use Core\Driver\SQL\SQL;
2020-06-24 16:09:04 +02:00
abstract class CondKeyword extends Condition {
2020-06-19 14:12:07 +02:00
private $leftExpression;
private $rightExpression;
2020-06-24 16:09:04 +02:00
private string $keyword;
2020-06-19 14:12:07 +02:00
2021-04-02 21:58:06 +02:00
public function __construct(string $keyword, $leftExpression, $rightExpression) {
2020-06-19 14:12:07 +02:00
$this->leftExpression = $leftExpression;
$this->rightExpression = $rightExpression;
2020-06-24 16:09:04 +02:00
$this->keyword = $keyword;
2020-06-19 14:12:07 +02:00
}
public function getLeftExp() { return $this->leftExpression; }
public function getRightExp() { return $this->rightExpression; }
2021-04-02 21:58:06 +02:00
public function getKeyword(): string { return $this->keyword; }
function getExpression(SQL $sql, array &$params): string {
$keyword = $this->getKeyword();
$left = $sql->addValue($this->getLeftExp(), $params);
$right = $sql->addValue($this->getRightExp(), $params);
return "$left $keyword $right";
}
2020-06-19 14:12:07 +02:00
}