From 6cd8159d8b476083aeebf3deb5543252638697b8 Mon Sep 17 00:00:00 2001 From: daitingting Date: Mon, 18 Mar 2024 06:38:44 +0000 Subject: [PATCH] * Add getPairs function in host model. --- module/host/model.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/module/host/model.php b/module/host/model.php index cbb59cee95..3c622a823c 100644 --- a/module/host/model.php +++ b/module/host/model.php @@ -64,6 +64,35 @@ class hostModel extends model ->fetchAll(); } + /** + * 获取主机键值对列表。 + * Get pairs. + * + * @param string $moduleIdList + * @access public + * @return array + */ + public function getPairs(string $moduleIdList = ''): array + { + $modules = array(); + if($moduleIdList) + { + $this->loadModel('tree'); + foreach(explode(',', $moduleIdList) as $moduleID) + { + if(empty($moduleID)) continue; + $modules += $this->tree->getAllChildId($moduleID); + } + } + + return $this->dao->select('id, name')->from(TABLE_HOST) + ->where('deleted')->eq('0') + ->andWhere('type')->eq('normal') + ->beginIF($modules)->andWhere('`group`')->in($modules)->fi() + ->orderBy('`group`') + ->fetchPairs(); + } + /** * 创建主机。 * create a host.