From 5bf2dda62bc96b2fadc285f4605b284b0dc9a070 Mon Sep 17 00:00:00 2001 From: zhouxin Date: Thu, 21 Nov 2024 14:40:53 +0800 Subject: [PATCH] * [task#133002,doing,0.2h] get max version. --- module/pivot/model.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/module/pivot/model.php b/module/pivot/model.php index 98ffdfebe5..39d9a5e79a 100644 --- a/module/pivot/model.php +++ b/module/pivot/model.php @@ -2827,6 +2827,26 @@ class pivotModel extends model { return $this->dao->select('*')->from(TABLE_PIVOTSPEC)->where('pivot')->eq($pivotID)->fetchAll(); } + + /** + * Get max version. + * + * @param int $pivotID + * @access public + * @return string + */ + public function getMaxVersion(int $pivotID): string + { + $versions = $this->dao->select('version')->from(TABLE_PIVOTSPEC)->where('pivot')->eq($pivotID)->fetchPairs(); + + $maxVersion = current($versions); + foreach($versions as $version) + { + if(version_compare($version, $maxVersion, '>')) $maxVersion = $version; + } + + return $maxVersion; + } } /**