+ [misc] add searchTables for multiple tables.

This commit is contained in:
qixinzhi
2024-06-11 03:24:27 +00:00
parent e003f2386f
commit 25ee10176b
+12
View File
@@ -86,6 +86,18 @@ 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));
/* 如果匹配不上,则字段没有使用别名进行限制,那么需要通过字段去遍历所有表。*/
/* 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)
{
/* 如果是原始表,并且列在原始表中存在,那么返回这个表。*/
/* If it is the original table and the column exists in the original table, then the table is returned. */
if($table['isTable'] && $this->columnExistInOriginTable($table['originTable'], $column)) return array_merge($table, array('column' => $column));
/* 如果不是原始表,并且列在子句中存在,那么返回子句中这个字段对应的表。*/
/* If it is not the original table and the column exists in the clause, then the table corresponding to the field in the clause is returned. */
if(!$table['isTable'] && isset($table['originTable'][$column])) return array_merge($table['originTable'][$column['table'], array('column' => $table['originTable'][$column['origin']));
}
return false;
}