优化HasOne的has方法

This commit is contained in:
thinkphp
2017-02-09 14:42:39 +08:00
parent a01c43472d
commit 532173e010

View File

@@ -65,7 +65,7 @@ class HasOne extends OneToOne
$foreignKey = $this->foreignKey;
return $this->parent->db()->alias('a')
->whereExists(function ($query) use ($table, $localKey, $foreignKey) {
$query->table([$table => 'b'])->whereExp('a.' . $localKey, '=b.' . $foreignKey);
$query->table([$table => 'b'])->field('b.' . $foreignKey)->whereExp('a.' . $localKey, '=b.' . $foreignKey);
});
}