From 2263ecf9a4e48e0f91cd884dbc7c9b8e68495743 Mon Sep 17 00:00:00 2001 From: zenggang Date: Thu, 13 Jan 2022 09:02:59 +0000 Subject: [PATCH] * Adjust code --- module/sonarqube/control.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/module/sonarqube/control.php b/module/sonarqube/control.php index f84333e39a..9bb891d738 100644 --- a/module/sonarqube/control.php +++ b/module/sonarqube/control.php @@ -92,14 +92,10 @@ class sonarqube extends control if(strpos($sonarqube->url, 'http') !== 0) return $this->send(array('result' => 'fail', 'message' => array('url' => array($this->lang->sonarqube->hostError)))); /* Check name and url unique. */ - if(empty($sonarqubeID)) - { - $existSonarQube = $this->dao->select('*')->from(TABLE_PIPELINE)->where("type='sonarqube' and (name='{$sonarqube->name}' or url='{$sonarqube->url}')")->fetch(); - } - else - { - $existSonarQube = $this->dao->select('*')->from(TABLE_PIPELINE)->where("id!={$sonarqubeID} and type='sonarqube' and (name='{$sonarqube->name}' or url='{$sonarqube->url}')")->fetch(); - } + $existSonarQube = $this->dao->select('*')->from(TABLE_PIPELINE) + ->where("type='sonarqube' and (name='{$sonarqube->name}' or url='{$sonarqube->url}')") + ->beginIF(!empty($sonarqubeID))->andWhere('id')->ne($sonarqubeID)->fi() + ->fetch(); if(isset($existSonarQube->name) and $existSonarQube->name == $sonarqube->name) return $this->send(array('result' => 'fail', 'message' => $this->lang->sonarqube->nameRepeatError)); if(isset($existSonarQube->url) and $existSonarQube->url== $sonarqube->url) return $this->send(array('result' => 'fail', 'message' => $this->lang->sonarqube->urlRepeatError));