2 Commits

Author SHA1 Message Date
a789231d5f v1.0.1 2022-09-08 22:14:40 -04:00
682f0b87fa v1.0.0 2022-09-08 17:43:43 -04:00
3 changed files with 7 additions and 35 deletions

View File

@ -65,7 +65,7 @@ abstract class Insert extends Query implements InsertInterface
}
public function addValue(int|string $value): InsertInterface
{
if (!is_numeric($value) and $value !== '?') {
if (!is_numeric($value)) {
$value = "'{$value}'";
}
$this->values []= $value;

View File

@ -51,10 +51,6 @@ abstract class Select extends Query implements SelectInterface
}
public function addColumn(string $column, ?string $alias = null): SelectInterface
{
if ($column === '*') {
$this->columns []= $column;
return $this;
}
$a = '';
if ($alias !== null) {
$a = " AS '{$alias}'";
@ -105,19 +101,7 @@ abstract class Select extends Query implements SelectInterface
}
public function getJoinString(): string
{
$str = [];
foreach ($this->getJoins() as $i => $join) {
if ($i === 0) {
$str []= $join;
continue;
}
if (!str_contains('and ', strtolower($join)) and !str_contains('or ', strtolower($join))) {
$str []= "AND {$join}";
continue;
}
$str []= $join;
}
return implode(' ', $str);
return implode(' ', $this->getJoins());
}
protected array $conditions;
public function setConditions(array $conditions): SelectInterface
@ -138,19 +122,7 @@ abstract class Select extends Query implements SelectInterface
}
public function getConditionString(): string
{
$str = [];
foreach ($this->getConditions() as $i => $condition) {
if ($i === 0) {
$str []= $condition;
continue;
}
if (!str_contains('and ', strtolower($condition)) and !str_contains('or ', strtolower($condition))) {
$str []= "AND {$condition}";
continue;
}
$str []= $condition;
}
return implode(' ', $str);
return implode(' ', $this->getConditions());
}
protected array $groups;
public function setGroups(array $groups): SelectInterface

View File

@ -20,18 +20,18 @@ class QueryBuilder implements QBInterface
public function select(array $columns = ['*']): Select
{
return $this->getContainer()->make(Select::class)->select($columns);
return $this->getContainer()->get(Select::class)->select($columns);
}
public function insert(string $table): Insert
{
return $this->getContainer()->make(Insert::class)->into($table);
return $this->getContainer()->get(Insert::class)->into($table);
}
public function update(string $table): Update
{
return $this->getContainer()->make(Update::class)->table($table);
return $this->getContainer()->get(Update::class)->table($table);
}
public function delete(string $table): Delete
{
return $this->getContainer()->make(Delete::class)->from($table);
return $this->getContainer()->get(Delete::class)->from($table);
}
}