simplification du code

This commit is contained in:
Gregory Letellier
2023-10-27 15:20:52 +02:00
parent 9e760fe6e5
commit 5c09234cf5

View File

@@ -226,31 +226,16 @@ 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; return "";
$iClause++;
}
}
return $ret;
} }
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) {
$ret = " LIMIT " . $this->take;
}
if ($this->offset !== null) {
$ret .= " OFFSET " . $this->offset;
}
return $ret; return $ret;
} else { } else {
return ""; return "";