- Merging
This commit is contained in:
commit
5a5d326d70
33 files changed
+763
-423
No files matched your search
@@ -12,4 +12,5 @@ interface QueryBuilderInterface
|
||||
public function reset() : void;
|
||||
public function getFragment(string $class, int $index = 0) : ? QueryFragmentInterface;
|
||||
public function removeFragment(QueryFragmentInterface|array|\Stringable|string $fragment) : void;
|
||||
public function hashSerializedQuery() : string;
|
||||
}
|
||||
@@ -432,8 +432,12 @@ class MysqlQueryBuilder extends SqlQueryBuilder
|
||||
return array_shift($this->queryStack);
|
||||
}
|
||||
|
||||
public function render(bool $skipToken = false) /* : mixed */
|
||||
public function render(bool $skipToken = false) : mixed
|
||||
{
|
||||
if (isset($this->rendered)) {
|
||||
return $this->rendered;
|
||||
}
|
||||
|
||||
$sql = [];
|
||||
|
||||
usort($this->queryStack, function($q1, $q2) {
|
||||
@@ -444,7 +448,7 @@ class MysqlQueryBuilder extends SqlQueryBuilder
|
||||
$sql[] = $fragment->render($skipToken);
|
||||
}
|
||||
|
||||
return implode(" ", $sql);
|
||||
return $this->rendered = implode(" ", $sql);
|
||||
}
|
||||
|
||||
public function reset() : void
|
||||
@@ -453,8 +457,7 @@ class MysqlQueryBuilder extends SqlQueryBuilder
|
||||
$this->whereConditionOperator = Query\Where::CONDITION_AND;
|
||||
$this->havingConditionOperator = Query\Where::CONDITION_AND;
|
||||
$this->parameterIndex = 0;
|
||||
|
||||
unset($this->where, $this->having);
|
||||
unset($this->where, $this->having, $this->rendered, $this->hash);
|
||||
}
|
||||
|
||||
public function getFragment(string $class, int $index = 0) : ? QueryFragmentInterface
|
||||
|
||||
@@ -7,6 +7,9 @@ use Ulmus\Query\QueryFragmentInterface;
|
||||
# TODO -> Extract from MysqlQueryBuilder to build an ISO/IEC 9075:2023 compatible layer for a basic SQL QueryBuilder
|
||||
class SqlQueryBuilder implements QueryBuilderInterface
|
||||
{
|
||||
protected string $rendered;
|
||||
|
||||
protected string $hash;
|
||||
|
||||
public function push(QueryFragmentInterface $queryFragment): QueryBuilderInterface
|
||||
{
|
||||
@@ -18,7 +21,7 @@ class SqlQueryBuilder implements QueryBuilderInterface
|
||||
// TODO: Implement pull() method.
|
||||
}
|
||||
|
||||
public function render(bool $skipToken = false)
|
||||
public function render(bool $skipToken = false) : mixed
|
||||
{
|
||||
// TODO: Implement render() method.
|
||||
}
|
||||
@@ -37,4 +40,9 @@ class SqlQueryBuilder implements QueryBuilderInterface
|
||||
{
|
||||
// TODO: Implement removeFragment() method.
|
||||
}
|
||||
|
||||
public function hashSerializedQuery(): string
|
||||
{
|
||||
return $this->hash ??= md5(sprintf("%s:%s", $this->render(), serialize($this->parameters)));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user