- A lot of fixes made again in this patch

This commit is contained in:
Dave Mc Nicoll committed 2021-05-24 20:03:38 +00:00
1 parent 4df9ececba
commit 7fb591e1f5
12 files changed
+222 -52

No files matched your search

+35 -2
View File
@@ -351,6 +351,30 @@ class QueryBuilder implements Query\QueryBuilderInterface
return $this;
}
public function alter(array $fieldlist, string $table, ? string $database = null, ? string $schema = null) : self
{
if ( null === $this->getFragment(Query\Create::class) ) {
if ( $schema ) {
$table = "$schema.$table";
}
if ( $database ) {
$table = "$database.$table";
}
$alter = new Query\Alter();
$this->push($alter);
$alter->fieldList = $fieldlist;
$alter->table = $table;
}
else {
throw new \Exception("A create SQL fragment was already found within the query builder");
}
return $this;
}
public function engine(string $value) : self
{
if ( null === $engine = $this->getFragment(Query\Engine::class) ) {
@@ -413,13 +437,22 @@ class QueryBuilder implements Query\QueryBuilderInterface
return null;
}
public function removeFragment(Query\Fragment $fragment) : void
public function removeFragment(/*Query\Fragment|array*/ $fragment) : void
{
is_object($fragment) && $fragment = get_class($fragment);
foreach($this->queryStack as $key => $item) {
if ( $item === $fragment ) {
if ( get_class($item) === $fragment ) {
unset($this->queryStack[$key]);
}
}
if ( $fragment === Query\Where::class ) {
unset($this->where);
}
elseif ( $fragment === Query\Having::class ) {
unset($this->having);
}
}
public function getFragments() : array