From af471fce9fb372c2958423dff97b81dff733fe2a Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 2 Jun 2023 00:49:22 +0000 Subject: [PATCH] * Fix incompatibility problem with the dm. --- config/zentaopms.php | 4 ++-- lib/dbh/dbh.class.php | 28 ++++++++++++++++++++++++++-- module/api/model.php | 8 ++++---- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/config/zentaopms.php b/config/zentaopms.php index 4422aea4af..4c7e58c970 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -230,11 +230,11 @@ $config->openMethods[] = 'feedback.mergeproductmodule'; $config->openMethods[] = 'zanode.nodelist'; $config->openMethods[] = 'action.restoreStages'; $config->openMethods[] = 'execution.browse'; -$config->openMethods[] = 'testcase.showImport'; +$config->openMethods[] = 'testcase.showimport'; $config->openMethods[] = 'testsuite.index'; $config->openMethods[] = 'caselib.index'; $config->openMethods[] = 'company.index'; -$config->openMethods[] = 'user.cropAvatar'; +$config->openMethods[] = 'user.cropavatar'; $config->openMethods[] = 'custom.index'; $config->openMethods[] = 'testcase.getxmindimport'; $config->openMethods[] = 'testcase.showxmindimport'; diff --git a/lib/dbh/dbh.class.php b/lib/dbh/dbh.class.php index fb16d8c7fd..25335a4ffe 100644 --- a/lib/dbh/dbh.class.php +++ b/lib/dbh/dbh.class.php @@ -254,8 +254,10 @@ class dbh */ public function formatDmSQL($sql) { - $sql = trim($sql); - $sql = str_replace(array('\r', '\n'), ' ', $sql); + $sql = trim($sql); + $sql = str_replace(array('\r', '\n'), ' ', $sql); + $sql = $this->formatFunction($sql); + $actionPos = strpos($sql, ' '); $action = strtoupper(substr($sql, 0, $actionPos)); $setPos = 0; @@ -361,6 +363,28 @@ class dbh } } + /** + * Format function. + * + * @param string $sql + * @access public + * @return string + */ + public function formatFunction($sql) + { + switch($this->config->driver) + { + case 'dm': + /* DATE convert to TO_CHAR. */ + $sql = preg_replace("/\bDATE\(([^)]*)\)/", "TO_CHAR($1, 'yyyy-mm-dd')", $sql, -1); + + return $sql; + + default: + return $sql; + } + } + /** * Format if function of dmdb. * diff --git a/module/api/model.php b/module/api/model.php index 936d5778df..910d1bd582 100644 --- a/module/api/model.php +++ b/module/api/model.php @@ -477,10 +477,10 @@ class apiModel extends model */ public function getStructByQuery($libID, $pager = '', $orderBy = '') { - return $this->dao->select('s.*,user.realname as addedName')->from(TABLE_APISTRUCT)->alias('s') - ->leftJoin(TABLE_USER)->alias('user')->on('user.account = s.addedBy') - ->where('s.deleted')->eq(0) - ->andWhere('s.lib')->eq($libID) + return $this->dao->select('t1.*,t2.realname as addedName')->from(TABLE_APISTRUCT)->alias('t1') + ->leftJoin(TABLE_USER)->alias('t2')->on('t2.account = t1.addedBy') + ->where('t1.deleted')->eq(0) + ->andWhere('t1.lib')->eq($libID) ->orderBy($orderBy) ->page($pager) ->fetchAll();