|
@@ -77,11 +77,21 @@ abstract class OneToOne extends Relation
|
|
|
$joinAlias = $relation;
|
|
|
$query->via($joinAlias);
|
|
|
|
|
|
+ //lizhen
|
|
|
+ if(strpos($this->foreignKey,'.')){
|
|
|
+ $new_foreignKey = $this->foreignKey;
|
|
|
+ }else{
|
|
|
+ $new_foreignKey = $name . '.' . $this->foreignKey;
|
|
|
+ }
|
|
|
+
|
|
|
if ($this instanceof BelongsTo) {
|
|
|
- $query->join([$joinTable => $joinAlias], $name . '.' . $this->foreignKey . '=' . $joinAlias . '.' . $this->localKey, $this->joinType);
|
|
|
+ $query->join([$joinTable => $joinAlias], $new_foreignKey . '=' . $joinAlias . '.' . $this->localKey, $this->joinType);
|
|
|
+ //$query->join([$joinTable => $joinAlias], $name . '.' . $this->foreignKey . '=' . $joinAlias . '.' . $this->localKey, $this->joinType);
|
|
|
} else {
|
|
|
$query->join([$joinTable => $joinAlias], $name . '.' . $this->localKey . '=' . $joinAlias . '.' . $this->foreignKey, $this->joinType);
|
|
|
}
|
|
|
+ //lizhen
|
|
|
+
|
|
|
|
|
|
if ($closure) {
|
|
|
// 执行闭包查询
|