simplification du code
This commit is contained in:
@@ -135,8 +135,8 @@ class QueryBuilder
|
|||||||
$ret->addData($value);
|
$ret->addData($value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$query = "UPDATE " . $this->table . " SET ";
|
$query = "UPDATE " . $this->table . " SET ";
|
||||||
$up = "";
|
$up = "";
|
||||||
foreach ($data as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
if ($up != "") {
|
if ($up != "") {
|
||||||
$up .= ", ";
|
$up .= ", ";
|
||||||
@@ -144,8 +144,8 @@ class QueryBuilder
|
|||||||
$up .= $key . " = ? ";
|
$up .= $key . " = ? ";
|
||||||
$ret->addData($value);
|
$ret->addData($value);
|
||||||
}
|
}
|
||||||
$query .= $up . " WHERE " . $this->pk . " = ? ;";
|
$query .= $up . " WHERE " . $this->pk . " = ? ;";
|
||||||
$ret->addData($data[$this->pk]);
|
$ret->addData($data[$this->pk]);
|
||||||
}
|
}
|
||||||
$ret->setQuery($query);
|
$ret->setQuery($query);
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -226,32 +226,17 @@ class QueryBuilder
|
|||||||
|
|
||||||
private function getClause(string $word, array $data): string
|
private function getClause(string $word, array $data): string
|
||||||
{
|
{
|
||||||
$ret = "";
|
if (!empty($data)) {
|
||||||
if (count($data) > 0) {
|
return " $word " . implode(",", $data);
|
||||||
$ret = " $word ";
|
|
||||||
$iClause = 0;
|
|
||||||
foreach ($data as $clause) {
|
|
||||||
if ($iClause > 0) {
|
|
||||||
$ret .= ",";
|
|
||||||
}
|
|
||||||
$ret .= $clause;
|
|
||||||
$iClause++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $ret;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getLimit(): string
|
private function getLimit(): string
|
||||||
{
|
{
|
||||||
if ($this->take !== null || $this->offset !== null) {
|
if ($this->take !== null || $this->offset !== null) {
|
||||||
$ret = "";
|
$ret = ($this->take !== null ? " LIMIT " . $this->take : "") . ($this->offset !== null ? " OFFSET " . $this->offset : "");
|
||||||
if ($this->take !== null) {
|
return $ret;
|
||||||
$ret = " LIMIT " . $this->take;
|
|
||||||
}
|
|
||||||
if ($this->offset !== null) {
|
|
||||||
$ret .= " OFFSET " . $this->offset;
|
|
||||||
}
|
|
||||||
return $ret;
|
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user