From 36ebc103fe9c6545bc080c4294e5ff28e141ec14 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 9 Oct 2023 14:27:24 +0800 Subject: [PATCH] * Refactor getLast method. --- module/release/control.php | 2 +- module/release/model.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/module/release/control.php b/module/release/control.php index dae5178a8e..4ba3ff50f7 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -122,7 +122,7 @@ class release extends control $this->view->productID = $productID; $this->view->builds = $builds; $this->view->users = $this->loadModel('user')->getPairs('noclosed'); - $this->view->lastRelease = $this->release->getLast($productID, $branch); + $this->view->lastRelease = $this->release->getLast($productID, (int)$branch); $this->display(); } diff --git a/module/release/model.php b/module/release/model.php index a4bac3a342..b13b9702a5 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -110,20 +110,20 @@ class releaseModel extends model } /** + * 获取产品下的最新创建的发布。 * Get last release. * - * @param int $productID - * @param int $branch + * @param int $productID + * @param int $branch * @access public - * @return bool | object + * @return object|false */ - public function getLast($productID, $branch = 0) + public function getLast(int $productID, int $branch = 0): object|false { return $this->dao->select('id, name')->from(TABLE_RELEASE) - ->where('product')->eq((int)$productID) + ->where('product')->eq($productID) ->beginIF($branch)->andWhere('branch')->eq($branch)->fi() ->orderBy('id DESC') - ->limit(1) ->fetch(); }