From b8ed622f966d6cc003c730a16ec50227f51179dc Mon Sep 17 00:00:00 2001 From: hainberg Date: Thu, 12 Sep 2019 13:53:39 +0200 Subject: [PATCH] Added method getParent() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This method gets only one parent of given organisational unit. This ist to easily retrieve department of a studiengang or fakultät of department etc. --- .../Organisationseinheit_model.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php index f9353c7b3..3efc8472a 100644 --- a/application/models/organisation/Organisationseinheit_model.php +++ b/application/models/organisation/Organisationseinheit_model.php @@ -165,4 +165,27 @@ class Organisationseinheit_model extends DB_Model return $this->execQuery(sprintf($query, $aktivstring, $aktivstring), array($oe_kurzbz)); } + /** + * Get one parent only. + * Easily retrieve department of a studiengang or fakultät of department etc. + * @param $oe_kurzbz + * @return array|null + */ + public function getParent($oe_kurzbz) + { + if (is_string($oe_kurzbz)) + { + $condition = ' + oe_kurzbz = ( + SELECT + oe_parent_kurzbz + FROM + public.tbl_organisationseinheit + WHERE + oe_kurzbz = \''. $oe_kurzbz. '\' + ) + '; + } + return $this->loadWhere($condition); + } }