This commit is contained in:
2021-02-24 19:08:42 +08:00
parent 4dddb833bb
commit b73f6b4f85
3 changed files with 1 additions and 24 deletions
-1
View File
@@ -152,7 +152,6 @@ class ActiveRecord extends BaseActiveRecord
if (empty($condition)) { if (empty($condition)) {
$condition = [$this->getPrimary() => $this->getPrimaryValue()]; $condition = [$this->getPrimary() => $this->getPrimaryValue()];
} }
$condition = static::find()->where($condition)->getCondition();
$execute = static::getDb()->createCommand() $execute = static::getDb()->createCommand()
->mathematics(self::getTable(), [$action => $columns], $condition); ->mathematics(self::getTable(), [$action => $columns], $condition);
if ($execute instanceof Command) { if ($execute instanceof Command) {
+1 -1
View File
@@ -144,7 +144,7 @@ class Command extends Component
public function mathematics($tableName, $param, $condition): bool|static public function mathematics($tableName, $param, $condition): bool|static
{ {
$change = $this->db->getSchema()->getChange(); $change = $this->db->getSchema()->getChange();
$sql = $change->mathematics($tableName, $param, $condition); $sql = $change->mathematics($tableName, $param, [$condition]);
if ($sql === false) { if ($sql === false) {
return false; return false;
} }
-22
View File
@@ -102,7 +102,6 @@ trait Condition
private function conditionMap($condition): string private function conditionMap($condition): string
{ {
$array = []; $array = [];
var_dump($condition);
if (is_string($condition) || empty($condition)) { if (is_string($condition) || empty($condition)) {
return $condition; return $condition;
} }
@@ -227,25 +226,4 @@ trait Condition
return ' LIMIT ' . $query->limit; return ' LIMIT ' . $query->limit;
} }
/**
* @param $value
* @param bool $isSearch
* @return int|string
*/
public function valueEncode($value, $isSearch = false): int|string
{
if ($isSearch) {
return $value;
}
if (is_numeric($value)) {
return $value;
} else {
if (!is_null(Json::decode($value))) {
return $value;
}
return '\'' . Str::encode($value) . '\'';
}
}
} }