- Multiple bugfixe linked to query fragments
- Added a new SearchRequest package to handle search request efficiently
This commit is contained in:
1 parent
4b29232543
commit
938639a590
15 files changed
+148
-27
No files matched your search
@@ -10,6 +10,6 @@ abstract class Fragment {
|
||||
|
||||
protected function renderSegments(array $segments, string $glue = " ") : string
|
||||
{
|
||||
return implode($glue, array_filter($segments));
|
||||
return implode($glue, array_filter($segments, function($i) { return ! is_null($i) && $i !== false && $i !== ""; }));
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,6 @@ class Insert extends Fragment {
|
||||
|
||||
protected function renderTable() : string
|
||||
{
|
||||
return $this->table;
|
||||
return "`$this->table`";
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ class Offset extends Fragment {
|
||||
public function set($offset) : self
|
||||
{
|
||||
$this->offset = $offset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,14 @@ class OrderBy extends Fragment {
|
||||
public function set(array $order) : self
|
||||
{
|
||||
$this->orderBy = $order;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function add(string $field, ? string $direction = null) : self
|
||||
{
|
||||
$this->orderBy[] = [ $field, $direction ];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -23,6 +25,7 @@ class OrderBy extends Fragment {
|
||||
{
|
||||
$list = array_map(function($item) {
|
||||
list($field, $direction) = $item;
|
||||
|
||||
return $field . ( $direction ? " $direction" : "" );
|
||||
}, $this->orderBy);
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ class Update extends Fragment {
|
||||
'UPDATE',
|
||||
( $this->priority ?? false ),
|
||||
( $this->ignore ? 'IGNORE' : false ),
|
||||
$this->table,
|
||||
$this->renderTable(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function renderTable() : string
|
||||
{
|
||||
return $this->table;
|
||||
return "`$this->table`";
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class Values extends Fragment {
|
||||
public function render() : string
|
||||
{
|
||||
$this->queryBuilder->addValues($this->flattenRowsArray());
|
||||
|
||||
|
||||
return $this->renderSegments([
|
||||
'VALUES', $this->renderParameterPlaceholders(),
|
||||
]);
|
||||
|
||||
Reference in new issue
Block a user