mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
DbObject: separate setting db properties
This commit is contained in:
parent
b4ffd5f02d
commit
24fff442e0
@ -477,14 +477,19 @@ abstract class DbObject
|
||||
protected function loadFromDb()
|
||||
{
|
||||
$select = $this->db->select()->from($this->table)->where($this->createWhere());
|
||||
$props = $this->db->fetchRow($select);
|
||||
$properties = $this->db->fetchRow($select);
|
||||
|
||||
if (empty($props)) {
|
||||
if (empty($properties)) {
|
||||
$msg = sprintf('Got no "%s" data for: %s', $this->table, $this->getId());
|
||||
throw new Exception($msg);
|
||||
}
|
||||
|
||||
foreach ($props as $key => $val) {
|
||||
return $this->setDbProperties($properties);
|
||||
}
|
||||
|
||||
protected function setDbProperties($properties)
|
||||
{
|
||||
foreach ($properties as $key => $val) {
|
||||
if (! array_key_exists($key, $this->properties)) {
|
||||
throw new Exception(sprintf(
|
||||
'Trying to set invalid %s key "%s". DB schema change?',
|
||||
|
Loading…
x
Reference in New Issue
Block a user