From 98d36f79bd645531e8996743bfa234c640f7eaab Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Tue, 11 Jun 2024 05:41:00 +0000 Subject: [PATCH] * [misc] fix column match error. --- lib/sqlparser/sqlparser.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/sqlparser/sqlparser.class.php b/lib/sqlparser/sqlparser.class.php index 4718cb8e1a..354fb28d3a 100644 --- a/lib/sqlparser/sqlparser.class.php +++ b/lib/sqlparser/sqlparser.class.php @@ -123,7 +123,7 @@ class sqlparser $fromTable = current($this->tables); foreach($this->columns as $columnName => $column) { - $column['table'] = array_merge($fromTable, array('column' => $columnName)); + $column['table'] = array_merge($fromTable, array('column' => $column['origin'])); $combineColumns[$columnName] = $column; } @@ -163,13 +163,13 @@ class sqlparser /* If it can be matched using an alias, then it returns. */ foreach($tables as $table) if($tableName == $table['alias']) return array_merge($table, array('column' => $column)); - $isTable = $table['isTable']; - $originTable = $table['originTable']; - /* 如果匹配不上,则字段没有使用别名进行限制,那么需要通过字段去遍历所有表。*/ /* If it doesn't match, then the field is not aliased, and you need to iterate over all tables using the field. */ foreach($tables as $table) { + $isTable = $table['isTable']; + $originTable = $table['originTable']; + /* 如果是原始表,并且列在原始表中存在,那么返回这个表。*/ /* If it is the original table and the column exists in the original table, then the table is returned. */ if($isTable && $this->columnExistInOriginTable($originTable, $column)) return array_merge($table, array('column' => $column));