Namespace and ClassPath rewrites

This commit is contained in:
2022-11-18 18:06:46 +01:00
parent c277aababc
commit 951ff14c5f
217 changed files with 1017 additions and 936 deletions

View File

@@ -0,0 +1,21 @@
<?php
namespace Core\Driver\SQL\Condition;
class Compare extends Condition {
private string $operator;
private string $column;
private $value;
public function __construct(string $col, $val, string $operator = '=') {
$this->operator = $operator;
$this->column = $col;
$this->value = $val;
}
public function getColumn(): string { return $this->column; }
public function getValue() { return $this->value; }
public function getOperator(): string { return $this->operator; }
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Core\Driver\SQL\Condition;
class CondAnd extends Condition {
private array $conditions;
public function __construct(...$conditions) {
$this->conditions = $conditions;
}
public function getConditions(): array { return $this->conditions; }
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Core\Driver\SQL\Condition;
class CondBool extends Condition {
private $value;
public function __construct($val) {
$this->value = $val;
}
public function getValue() { return $this->value; }
}

View File

@@ -0,0 +1,17 @@
<?php
namespace Core\Driver\SQL\Condition;
class CondIn extends Condition {
private $needle;
private $haystack;
public function __construct($needle, $haystack) {
$this->needle = $needle;
$this->haystack = $haystack;
}
public function getNeedle() { return $this->needle; }
public function getHaystack() { return $this->haystack; }
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Core\Driver\SQL\Condition;
abstract class CondKeyword extends Condition {
private $leftExpression;
private $rightExpression;
private string $keyword;
public function __construct(string $keyword, $leftExpression, $rightExpression) {
$this->leftExpression = $leftExpression;
$this->rightExpression = $rightExpression;
$this->keyword = $keyword;
}
public function getLeftExp() { return $this->leftExpression; }
public function getRightExp() { return $this->rightExpression; }
public function getKeyword(): string { return $this->keyword; }
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Core\Driver\SQL\Condition;
class CondLike extends CondKeyword {
public function __construct($leftExpression, $rightExpression) {
parent::__construct("LIKE", $leftExpression, $rightExpression);
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Core\Driver\SQL\Condition;
class CondNot extends Condition {
private $expression; // string or condition
public function __construct($expression) {
$this->expression = $expression;
}
public function getExpression() {
return $this->expression;
}
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Core\Driver\SQL\Condition;
class CondNull extends Condition {
private string $column;
public function __construct(string $col) {
$this->column = $col;
}
public function getColumn(): string { return $this->column; }
}

View File

@@ -0,0 +1,14 @@
<?php
namespace Core\Driver\SQL\Condition;
class CondOr extends Condition {
private array $conditions;
public function __construct(...$conditions) {
$this->conditions = (!empty($conditions) && is_array($conditions[0])) ? $conditions[0] : $conditions;
}
public function getConditions(): array { return $this->conditions; }
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Core\Driver\SQL\Condition;
class CondRegex extends CondKeyword {
public function __construct($leftExpression, $rightExpression) {
parent::__construct("REGEXP", $leftExpression, $rightExpression);
}
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Core\Driver\SQL\Condition;
use Core\Driver\SQL\Expression\Expression;
abstract class Condition extends Expression {
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Core\Driver\SQL\Condition;
use Core\Driver\SQL\Query\Select;
class Exists extends Condition
{
private Select $subQuery;
public function __construct(Select $subQuery)
{
$this->subQuery = $subQuery;
}
public function getSubQuery(): Select
{
return $this->subQuery;
}
}