- Still working on Update and Insert statements

This commit is contained in:
mcndave committed 2020-02-05 23:41:57 -05:00
1 parent 828daffec8
commit 3dc82b1f0d
11 files changed
+243 -62

No files matched your search

+41 -3
View File
@@ -51,7 +51,7 @@ class QueryBuilder
$insert = new Query\Insert();
$this->push($insert);
$insert->fieldist = $fieldlist;
$insert->fieldlist = $fieldlist;
$insert->alias = $alias;
$insert->table = $table;
}
@@ -63,7 +63,7 @@ class QueryBuilder
{
if ( false === ( $values = $this->has(Query\Values::class) ) ) {
$values = new Query\Values();
$values = new Query\Values($this);
$this->push($values);
}
@@ -72,6 +72,40 @@ class QueryBuilder
return $this;
}
public function update(string $table, ? string $alias = null, ? string $database = null, ? string $schema = null) : self
{
if ( ! $this->has(Query\Update::class) ) {
if ( $database ) {
$table = "\"$database\".$table";
}
if ( $schema ) {
$table = "\"$schema\".$table";
}
$update = new Query\Update();
$this->push($update);
$update->alias = $alias;
$update->table = $table;
}
return $this;
}
public function set(array $dataset) : self
{
if ( false === ( $values = $this->has(Query\Set::class) ) ) {
$set = new Query\Set($this);
$this->push($set);
}
$set->set($dataset);
return $this;
}
public function delete() : self
{
if ( ! $this->has(Query\Delete::class) ) {
@@ -180,12 +214,14 @@ class QueryBuilder
}
$orderBy->add($field, $direction);
return $this;
}
public function push(Query\Fragment $queryFragment) : self
{
$this->queryStack[] = $queryFragment;
return $this;
}
@@ -226,10 +262,12 @@ class QueryBuilder
}
$this->parameters[$key] = $value;
return $key;
}
public function addValues(array $values) {
public function addValues(array $values) : void
{
$this->values = $values;
}
}