summaryrefslogtreecommitdiff
path: root/app/Model/Base.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/Base.php')
-rw-r--r--app/Model/Base.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/Model/Base.php b/app/Model/Base.php
index 5a8d8f1c..59fbf7b6 100644
--- a/app/Model/Base.php
+++ b/app/Model/Base.php
@@ -91,6 +91,26 @@ abstract class Base
}
/**
+ * Save a record in the database
+ *
+ * @access public
+ * @param string $table Table name
+ * @param array $values Form values
+ * @return boolean|integer
+ */
+ public function persist($table, array $values)
+ {
+ return $this->db->transaction(function($db) use ($table, $values) {
+
+ if (! $db->table($table)->save($values)) {
+ return false;
+ }
+
+ return (int) $db->getConnection()->getLastId();
+ });
+ }
+
+ /**
* Remove keys from an array
*
* @access public