- Still working on Update and Insert statements
This commit is contained in:
1 parent
828daffec8
commit
3dc82b1f0d
11 files changed
+243
-62
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Query;
|
||||
|
||||
use Ulmus\QueryBuilder;
|
||||
|
||||
class Set extends Fragment {
|
||||
|
||||
public int $order = 0;
|
||||
|
||||
public array $dataset;
|
||||
|
||||
public QueryBuilder $queryBuilder;
|
||||
|
||||
public function __construct(QueryBuilder $queryBuilder)
|
||||
{
|
||||
$this->queryBuilder = $queryBuilder;
|
||||
}
|
||||
|
||||
public function set(array $dataset) : self
|
||||
{
|
||||
$this->dataset = $dataset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() : string
|
||||
{
|
||||
return $this->renderSegments([
|
||||
'SET', $this->renderParameterPlaceholders(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function renderParameterPlaceholders() : string
|
||||
{
|
||||
$keys = [];
|
||||
|
||||
foreach($this->dataset as $key =>$value) {
|
||||
$this->queryBuilder->addParameter($value, ":v_$key");
|
||||
$keys[] = "$key=:v_$key";
|
||||
}
|
||||
|
||||
return implode(",", $keys);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user