mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 23:02:48 +08:00
改进HasMany关联的getRelationCountQuery方法
This commit is contained in:
@@ -159,11 +159,11 @@ class HasMany extends Relation
|
|||||||
if ($closure) {
|
if ($closure) {
|
||||||
call_user_func_array($closure, [ & $this->query]);
|
call_user_func_array($closure, [ & $this->query]);
|
||||||
}
|
}
|
||||||
|
$localKey = $this->localKey ?: $this->parent->getPk();
|
||||||
return $this->query->where([
|
return $this->query->where([
|
||||||
$this->foreignKey => [
|
$this->foreignKey => [
|
||||||
'exp',
|
'exp',
|
||||||
'=' . $this->parent->getTable() . '.' . $this->parent->getPk(),
|
'=' . $this->parent->getTable() . '.' . $localKey,
|
||||||
],
|
],
|
||||||
])->fetchSql()->count();
|
])->fetchSql()->count();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user