From 7d35e336b532aad3833068d4c93bf69c2eefde08 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 29 Aug 2023 10:44:55 +0800 Subject: [PATCH] + Add fetchByID method. --- framework/model.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/framework/model.class.php b/framework/model.class.php index 54a747f89e..3157999ad4 100644 --- a/framework/model.class.php +++ b/framework/model.class.php @@ -223,6 +223,23 @@ class model extends baseModel return $menu; } + /** + * 通过对象ID获取对象信息。 + * Get object information by ID. + * + * @param int $objectID + * @param string $moduleName + * @access public + * @return object|bool + */ + public function fetchByID(int $objectID, string $moduleName = ''): object|bool + { + if(empty($moduleName)) $moduleName = $this->getModuleName(); + $table = $this->config->objectTables[$moduleName]; + + return $this->dao->findById($objectID)->from($table)->fetch(); + } + /** * Process status of an object according to its subStatus. *