diff --git a/library/think/db/Builder.php b/library/think/db/Builder.php index 232e7b16..69484ffe 100644 --- a/library/think/db/Builder.php +++ b/library/think/db/Builder.php @@ -442,8 +442,12 @@ abstract class Builder list($table, $type, $on) = $item; $condition = []; foreach ((array) $on as $val) { - list($val1, $val2) = explode('=', $val, 2); - $condition[] = $this->parseKey($val1, $options) . '=' . $this->parseKey($val2, $options); + if (strpos($val, '=')) { + list($val1, $val2) = explode('=', $val, 2); + $condition[] = $this->parseKey($val1, $options) . '=' . $this->parseKey($val2, $options); + } else { + $condition[] = $val; + } } $table = $this->parseTable($table, $options); diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 2e37e1a3..ec37e49d 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -666,22 +666,25 @@ class Query $prefix = $this->prefix; // 传入的表名为数组 if (is_array($join)) { + if (count($join) > 1) { + $prefix = array_pop($join); + } if (0 !== $key = key($join)) { // 设置了键名则键名为表名,键值作为表的别名 $table = $key; + if (false === strpos($table, '.')) { + $table = $prefix . $table; + } $alias = array_shift($join); $this->alias([$table => $alias]); $table = [$table => $alias]; } else { $table = array_shift($join); + if (false === strpos($table, '.')) { + $table = $prefix . $table; + } } - if (count($join)) { - // 有设置第二个元素则把第二元素作为表前缀 - $table = (string) current($join) . $table; - } elseif (false === strpos($table, '.')) { - // 加上默认的表前缀 - $table = $prefix . $table; - } + } else { $join = trim($join); if (0 === strpos($join, '__')) {