eee
This commit is contained in:
+23
-23
@@ -52,7 +52,7 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
public function getCondition(): string
|
||||
{
|
||||
return $this->where($this->query->getWhere());
|
||||
return $this->where($this->query);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
public function update(array $attributes): bool|string
|
||||
{
|
||||
$conditions = $this->query->getParams();
|
||||
$this->query->setParams([]);
|
||||
$data = $this->__updateBuilder($this->makeParams($attributes));
|
||||
$conditions = $this->query;
|
||||
$this->query = [];
|
||||
$data = $this->__updateBuilder($this->makeParams($attributes));
|
||||
foreach ($conditions as $condition) {
|
||||
$this->query->pushParam($condition);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class SqlBuilder extends Component
|
||||
if (empty($string)) {
|
||||
return Kiri::getLogger()->logCategory('None data update.');
|
||||
}
|
||||
return 'UPDATE ' . $this->query->getFrom() . ' SET ' . implode(',', $string) . $this->make();
|
||||
return 'UPDATE ' . $this->query . ' SET ' . implode(',', $string) . $this->make();
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
public function insert(array $attributes, bool $isBatch = false): string
|
||||
{
|
||||
$update = 'INSERT INTO ' . $this->query->getFrom();
|
||||
$update = 'INSERT INTO ' . $this->query;
|
||||
if ($isBatch === false) {
|
||||
$attributes = [$attributes];
|
||||
}
|
||||
@@ -144,7 +144,7 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
public function delete(): string
|
||||
{
|
||||
return 'DELETE FROM ' . $this->query->getFrom() . $this->make();
|
||||
return 'DELETE FROM ' . $this->query . $this->make();
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ class SqlBuilder extends Component
|
||||
public function one(): string
|
||||
{
|
||||
$this->query->offset(0)->limit(1);
|
||||
return $this->makeSelect($this->query->getSelect()) . $this->make() . $this->makeLimit();
|
||||
return $this->makeSelect($this->query) . $this->make() . $this->makeLimit();
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
public function all(): string
|
||||
{
|
||||
return $this->makeSelect($this->query->getSelect()) . $this->make() . $this->makeLimit();
|
||||
return $this->makeSelect($this->query) . $this->make() . $this->makeLimit();
|
||||
}
|
||||
|
||||
|
||||
@@ -286,12 +286,12 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
private function makeSelect(array $select = ['*']): string
|
||||
{
|
||||
$select = "SELECT " . implode(',', $select) . " FROM " . $this->query->getFrom();
|
||||
if ($this->query->getAlias() != "") {
|
||||
$select .= " AS " . $this->query->getAlias();
|
||||
$select = "SELECT " . implode(',', $select) . " FROM " . $this->query;
|
||||
if ($this->query != "") {
|
||||
$select .= " AS " . $this->query;
|
||||
}
|
||||
if (count($this->query->getJoin()) > 0) {
|
||||
$select .= ' ' . implode(' ', $this->query->getJoin());
|
||||
if (count($this->query) > 0) {
|
||||
$select .= ' ' . implode(' ', $this->query);
|
||||
}
|
||||
return $select;
|
||||
}
|
||||
@@ -302,8 +302,8 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
private function makeGroup(): string
|
||||
{
|
||||
if ($this->query->getGroup() != "") {
|
||||
return ' GROUP BY ' . $this->query->getGroup();
|
||||
if ($this->query != "") {
|
||||
return ' GROUP BY ' . $this->query;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -314,8 +314,8 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
private function makeOrder(): string
|
||||
{
|
||||
if (count($this->query->getOrder()) > 0) {
|
||||
return ' ORDER BY ' . implode(',', $this->query->getOrder());
|
||||
if (count($this->query) > 0) {
|
||||
return ' ORDER BY ' . implode(',', $this->query);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -326,7 +326,7 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
private function makeCondition(): string
|
||||
{
|
||||
$condition = $this->where($this->query->getWhere());
|
||||
$condition = $this->where($this->query);
|
||||
if (empty($condition)) {
|
||||
return '';
|
||||
}
|
||||
@@ -340,14 +340,14 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
private function makeLimit(): string
|
||||
{
|
||||
if ($this->query->getOffset() >= 0 && $this->query->getLimit() >= 1) {
|
||||
if ($this->query >= 0 && $this->query >= 1) {
|
||||
$driver = $this->getDriver();
|
||||
if (in_array($driver, ['pgsql', 'postgresql'])) {
|
||||
// PostgreSQL 使用 LIMIT ... OFFSET ... 语法
|
||||
return ' LIMIT ' . $this->query->getLimit() . ' OFFSET ' . $this->query->getOffset();
|
||||
return ' LIMIT ' . $this->query . ' OFFSET ' . $this->query;
|
||||
}
|
||||
// MySQL 使用 LIMIT offset,limit 语法
|
||||
return ' LIMIT ' . $this->query->getOffset() . ',' . $this->query->getLimit();
|
||||
return ' LIMIT ' . $this->query . ',' . $this->query;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@@ -373,7 +373,7 @@ class SqlBuilder extends Component
|
||||
*/
|
||||
public function truncate(): string
|
||||
{
|
||||
return sprintf('TRUNCATE %s', $this->query->getFrom());
|
||||
return sprintf('TRUNCATE %s', $this->query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user