summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Metadata.php21
-rw-r--r--app/Model/Setting.php13
2 files changed, 28 insertions, 6 deletions
diff --git a/app/Model/Metadata.php b/app/Model/Metadata.php
index 9b26e404..01799a40 100644
--- a/app/Model/Metadata.php
+++ b/app/Model/Metadata.php
@@ -83,16 +83,29 @@ abstract class Metadata extends Base
$results = array();
$user_id = $this->userSession->getId();
$timestamp = time();
-
+
$this->db->startTransaction();
-
+
foreach ($values as $key => $value) {
if ($this->exists($entity_id, $key)) {
- $results[] = $this->db->table(static::TABLE)->eq($this->getEntityKey(), $entity_id)->eq('name', $key)->update(array('value' => $value, 'changed_on' => $timestamp, 'changed_by' => $user_id));
+ $results[] = $this->db->table(static::TABLE)
+ ->eq($this->getEntityKey(), $entity_id)
+ ->eq('name', $key)->update(array(
+ 'value' => $value,
+ 'changed_on' => $timestamp,
+ 'changed_by' => $user_id,
+ ));
} else {
- $results[] = $this->db->table(static::TABLE)->insert(array('name' => $key, 'value' => $value, $this->getEntityKey() => $entity_id, 'changed_on' => $timestamp, 'changed_by' => $user_id));
+ $results[] = $this->db->table(static::TABLE)->insert(array(
+ 'name' => $key,
+ 'value' => $value,
+ $this->getEntityKey() => $entity_id,
+ 'changed_on' => $timestamp,
+ 'changed_by' => $user_id,
+ ));
}
}
+
$this->db->closeTransaction();
return ! in_array(false, $results, true);
}
diff --git a/app/Model/Setting.php b/app/Model/Setting.php
index 4e1c1b0b..f98d7ce1 100644
--- a/app/Model/Setting.php
+++ b/app/Model/Setting.php
@@ -88,9 +88,18 @@ abstract class Setting extends Base
foreach ($values as $option => $value) {
if ($this->exists($option)) {
- $results[] = $this->db->table(self::TABLE)->eq('option', $option)->update(array('value' => $value, 'changed_on' => $timestamp, 'changed_by' => $user_id));
+ $results[] = $this->db->table(self::TABLE)->eq('option', $option)->update(array(
+ 'value' => $value,
+ 'changed_on' => $timestamp,
+ 'changed_by' => $user_id,
+ ));
} else {
- $results[] = $this->db->table(self::TABLE)->insert(array('option' => $option, 'value' => $value, 'changed_on' => $timestamp, 'changed_by' => $user_id));
+ $results[] = $this->db->table(self::TABLE)->insert(array(
+ 'option' => $option,
+ 'value' => $value,
+ 'changed_on' => $timestamp,
+ 'changed_by' => $user_id,
+ ));
}
}