- A lot of bugfixes, mainly with escaping (still working on it to get 100% coverage)
This commit is contained in:
1 parent
e3d0e45a4e
commit
3905047111
8 files changed
+91
-126
No files matched your search
@@ -22,14 +22,13 @@ class Create extends Fragment {
|
||||
public function render() : string
|
||||
{
|
||||
return $this->renderSegments([
|
||||
static::SQL_TOKEN, $this->renderTables($this->table),
|
||||
$this->renderFields(),
|
||||
static::SQL_TOKEN, $this->renderTables($this->table), $this->renderFields(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function renderFields() : string
|
||||
{
|
||||
return "(" . PHP_EOL . implode(",".PHP_EOL, array_map(function($field) {
|
||||
return "(" . PHP_EOL . implode("," . PHP_EOL, array_map(function($field) {
|
||||
return " " . EntityField::generateCreateColumn($field);
|
||||
}, $this->fieldList)) . PHP_EOL . ")";
|
||||
}
|
||||
|
||||
+11
-5
@@ -9,7 +9,9 @@ class Set extends Fragment {
|
||||
public int $order = 0;
|
||||
|
||||
public array $dataset;
|
||||
|
||||
|
||||
public ? array $escapedFields;
|
||||
|
||||
public QueryBuilderInterface $queryBuilder;
|
||||
|
||||
public function __construct(QueryBuilderInterface $queryBuilder)
|
||||
@@ -17,10 +19,11 @@ class Set extends Fragment {
|
||||
$this->queryBuilder = $queryBuilder;
|
||||
}
|
||||
|
||||
public function set(array $dataset) : self
|
||||
public function set(array $dataset, ? array $escapedFields = null) : self
|
||||
{
|
||||
$this->dataset = $dataset;
|
||||
|
||||
$this->escapedFields = $escapedFields;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -34,10 +37,13 @@ class Set extends Fragment {
|
||||
public function renderParameterPlaceholders() : string
|
||||
{
|
||||
$keys = [];
|
||||
|
||||
|
||||
foreach($this->dataset as $key =>$value) {
|
||||
$this->queryBuilder->addParameter($value, ":v_$key");
|
||||
$keys[] = "$key=:v_$key";
|
||||
|
||||
$field = $this->escapedFields[$key] ?? $key;
|
||||
|
||||
$keys[] = "{$field}=:v_{$key}";
|
||||
}
|
||||
|
||||
return implode(",", $keys);
|
||||
|
||||
Reference in new issue
Block a user