summaryrefslogtreecommitdiff
path: root/app/Model/Metadata.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/Metadata.php')
-rw-r--r--app/Model/Metadata.php21
1 files changed, 17 insertions, 4 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);
}