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
|
|
|
|
2023-01-05 22:47:17 +01: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; }
|
2023-01-05 22:47:17 +01:00
|
|
|
|
|
|
|
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
|
|
|
}
|