mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing useless loop in Model::save()
This commit is contained in:
parent
0c951b7248
commit
8375570f8a
1 changed files with 10 additions and 15 deletions
|
@ -1327,21 +1327,16 @@ class Model extends Overloadable {
|
||||||
if (!empty($this->id)) {
|
if (!empty($this->id)) {
|
||||||
$success = (bool)$db->update($this, $fields, $values);
|
$success = (bool)$db->update($this, $fields, $values);
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->_schema as $field => $properties) {
|
$fInfo = $this->_schema[$this->primaryKey];
|
||||||
if ($this->primaryKey === $field) {
|
$isUUID = ($fInfo['length'] == 36 &&
|
||||||
$fInfo = $this->_schema[$field];
|
($fInfo['type'] === 'string' || $fInfo['type'] === 'binary')
|
||||||
$isUUID = ($fInfo['length'] == 36 &&
|
);
|
||||||
($fInfo['type'] === 'string' || $fInfo['type'] === 'binary')
|
if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) {
|
||||||
);
|
if (array_key_exists($this->primaryKey, $this->data[$this->alias])) {
|
||||||
if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) {
|
$j = array_search($this->primaryKey, $fields);
|
||||||
if (array_key_exists($this->primaryKey, $this->data[$this->alias])) {
|
$values[$j] = String::uuid();
|
||||||
$j = array_search($this->primaryKey, $fields);
|
} else {
|
||||||
$values[$j] = String::uuid();
|
list($fields[], $values[]) = array($this->primaryKey, String::uuid());
|
||||||
} else {
|
|
||||||
list($fields[], $values[]) = array($this->primaryKey, String::uuid());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue