mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
DbObject: allow to change primary key (not autoinc)
This commit is contained in:
parent
2b9848f9e2
commit
41d6f47752
@ -283,8 +283,8 @@ abstract class DbObject
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key === $this->getKeyName() && $this->hasBeenLoadedFromDb()) {
|
if ($key === $this->getAutoincKeyName()) {
|
||||||
throw new IE('Changing primary key is not allowed');
|
throw new IE('Changing autoincremental key is not allowed');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->reallySet($key, $value);
|
return $this->reallySet($key, $value);
|
||||||
@ -389,7 +389,7 @@ abstract class DbObject
|
|||||||
{
|
{
|
||||||
$props = array();
|
$props = array();
|
||||||
foreach (array_keys($this->modifiedProperties) as $key) {
|
foreach (array_keys($this->modifiedProperties) as $key) {
|
||||||
if ($key === $this->keyName || $key === $this->autoincKeyName) continue;
|
if ($key === $this->autoincKeyName) continue;
|
||||||
$props[$key] = $this->properties[$key];
|
$props[$key] = $this->properties[$key];
|
||||||
}
|
}
|
||||||
return $props;
|
return $props;
|
||||||
@ -769,10 +769,17 @@ abstract class DbObject
|
|||||||
}
|
}
|
||||||
return implode(' AND ', $where);
|
return implode(' AND ', $where);
|
||||||
} else {
|
} else {
|
||||||
return $this->db->quoteInto(
|
if ($this->hasBeenLoadedFromDb()) {
|
||||||
sprintf('%s = ?', $key),
|
return $this->db->quoteInto(
|
||||||
$this->properties[$key]
|
sprintf('%s = ?', $key),
|
||||||
);
|
$this->loadedProperties[$key]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return $this->db->quoteInto(
|
||||||
|
sprintf('%s = ?', $key),
|
||||||
|
$this->properties[$key]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user