Skip to content

Commit d0ca14c

Browse files
committed
update 不对column做处理 用raw防止被格式化 导致无法运行自带方法(如:count,min,max等)
1 parent b1fdfe5 commit d0ca14c

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

app/ApiJson/Entity/ConditionEntity.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ConditionEntity
1313

1414
protected int $limit = 10;
1515
protected int $offset = 0;
16-
protected array $column = ['*'];
16+
protected string $column = '*';
1717
protected array $group = [];
1818
protected array $order = [];
1919
protected array $having = [];
@@ -60,9 +60,9 @@ public function addQueryWhere(string $key, string $sql, array $bindArgs = [])
6060
}
6161

6262
/**
63-
* @param array|string[] $column
63+
* @param string $column
6464
*/
65-
public function setColumn(array $column): void
65+
public function setColumn(string $column): void
6666
{
6767
$this->column = $column;
6868
}
@@ -108,9 +108,9 @@ public function setOrder(array $order): void
108108
}
109109

110110
/**
111-
* @return array
111+
* @return string
112112
*/
113-
public function getColumn(): array
113+
public function getColumn(): string
114114
{
115115
return $this->column;
116116
}

app/ApiJson/Handle/FunctionColumnHandle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function buildModel()
1616
}, ARRAY_FILTER_USE_KEY) as $key => $value)
1717
{
1818
$value = str_replace([';',':'], [',', ' AS '], $value);
19-
$this->condition->setColumn(explode(',', $value));
19+
$this->condition->setColumn($value);
2020
$this->unsetKey[] = $this->keyWord;
2121
}
2222
}

app/ApiJson/Model/MysqlQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected function buildQuery(bool $query = true)
102102
}
103103
if (!$query) return; //下面不再非查询操作
104104

105-
$this->db->select($this->conditionEntity->getColumn());
105+
$this->db->select(Db::raw($this->conditionEntity->getColumn()));
106106
$limit = $this->conditionEntity->getLimit();
107107
if ($limit > 0) {
108108
$this->db->limit($limit);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy