diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-22 18:49:34 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-22 18:49:34 -0500 |
commit | c49d46718a07afeea017aa90a60320587211dc49 (patch) | |
tree | 68499594b8d2f6a26411249aaff12b87b4ee3628 /app/Model/Base.php | |
parent | 77e10d25829f3523a168bf61424fac99a539f8be (diff) |
Some refactoring for PHP 5.3
Diffstat (limited to 'app/Model/Base.php')
-rw-r--r-- | app/Model/Base.php | 20 |
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 |