From be2fde7cc01228ad4526e05d77a3d4865e550357 Mon Sep 17 00:00:00 2001 From: middeke Date: Wed, 23 Dec 2015 00:03:56 +0100 Subject: remove function for MetaData --- app/Model/Metadata.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'app') diff --git a/app/Model/Metadata.php b/app/Model/Metadata.php index 83c8f499..ae7475c4 100644 --- a/app/Model/Metadata.php +++ b/app/Model/Metadata.php @@ -95,4 +95,27 @@ abstract class Metadata extends Base return ! in_array(false, $results, true); } + + /** + * Remove a metadata + * + * @access public + * @param integer $entity_id + * @param string $name + * @return bool + */ + public function remove($entity_id, $name) + { + + $this->db->startTransaction(); + + if (! $this->db->table(static::TABLE)->eq($this->getEntityKey(), $entity_id)->eq('name', $name)->remove()) { + $this->db->cancelTransaction(); + return false; + } + + $this->db->closeTransaction(); + + return true; + } } -- cgit v1.2.3