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