Compare commits
8 Commits
1.0.1
...
946a0b0b5e
Author | SHA1 | Date | |
---|---|---|---|
946a0b0b5e | |||
3b1902ed1a | |||
e7ab3fb8b7 | |||
d4fecf977d | |||
a22a927bb4 | |||
758a4b7c7f | |||
2fd0af5c2f | |||
97d5ae8450 |
@ -65,7 +65,7 @@ abstract class Insert extends Query implements InsertInterface
|
|||||||
}
|
}
|
||||||
public function addValue(int|string $value): InsertInterface
|
public function addValue(int|string $value): InsertInterface
|
||||||
{
|
{
|
||||||
if (!is_numeric($value)) {
|
if (!is_numeric($value) and $value !== '?') {
|
||||||
$value = "'{$value}'";
|
$value = "'{$value}'";
|
||||||
}
|
}
|
||||||
$this->values []= $value;
|
$this->values []= $value;
|
||||||
|
@ -51,6 +51,10 @@ abstract class Select extends Query implements SelectInterface
|
|||||||
}
|
}
|
||||||
public function addColumn(string $column, ?string $alias = null): SelectInterface
|
public function addColumn(string $column, ?string $alias = null): SelectInterface
|
||||||
{
|
{
|
||||||
|
if ($column === '*') {
|
||||||
|
$this->columns []= $column;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
$a = '';
|
$a = '';
|
||||||
if ($alias !== null) {
|
if ($alias !== null) {
|
||||||
$a = " AS '{$alias}'";
|
$a = " AS '{$alias}'";
|
||||||
@ -101,7 +105,19 @@ abstract class Select extends Query implements SelectInterface
|
|||||||
}
|
}
|
||||||
public function getJoinString(): string
|
public function getJoinString(): string
|
||||||
{
|
{
|
||||||
return implode(' ', $this->getJoins());
|
$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);
|
||||||
}
|
}
|
||||||
protected array $conditions;
|
protected array $conditions;
|
||||||
public function setConditions(array $conditions): SelectInterface
|
public function setConditions(array $conditions): SelectInterface
|
||||||
@ -122,7 +138,19 @@ abstract class Select extends Query implements SelectInterface
|
|||||||
}
|
}
|
||||||
public function getConditionString(): string
|
public function getConditionString(): string
|
||||||
{
|
{
|
||||||
return implode(' ', $this->getConditions());
|
$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);
|
||||||
}
|
}
|
||||||
protected array $groups;
|
protected array $groups;
|
||||||
public function setGroups(array $groups): SelectInterface
|
public function setGroups(array $groups): SelectInterface
|
||||||
|
@ -20,18 +20,18 @@ class QueryBuilder implements QBInterface
|
|||||||
|
|
||||||
public function select(array $columns = ['*']): Select
|
public function select(array $columns = ['*']): Select
|
||||||
{
|
{
|
||||||
return $this->getContainer()->get(Select::class)->select($columns);
|
return $this->getContainer()->make(Select::class)->select($columns);
|
||||||
}
|
}
|
||||||
public function insert(string $table): Insert
|
public function insert(string $table): Insert
|
||||||
{
|
{
|
||||||
return $this->getContainer()->get(Insert::class)->into($table);
|
return $this->getContainer()->make(Insert::class)->into($table);
|
||||||
}
|
}
|
||||||
public function update(string $table): Update
|
public function update(string $table): Update
|
||||||
{
|
{
|
||||||
return $this->getContainer()->get(Update::class)->table($table);
|
return $this->getContainer()->make(Update::class)->table($table);
|
||||||
}
|
}
|
||||||
public function delete(string $table): Delete
|
public function delete(string $table): Delete
|
||||||
{
|
{
|
||||||
return $this->getContainer()->get(Delete::class)->from($table);
|
return $this->getContainer()->make(Delete::class)->from($table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user