修正关联withCount查询

This commit is contained in:
thinkphp
2018-04-16 12:46:58 +08:00
parent 3bf48cbfef
commit 513701788e
3 changed files with 6 additions and 9 deletions

View File

@@ -11,6 +11,7 @@
namespace think\model\relation;
use think\Db;
use think\db\Query;
use think\Exception;
use think\Loader;
@@ -201,7 +202,7 @@ class MorphMany extends Relation
return $this->query->where([
$this->morphKey => [
'exp',
'=' . $this->parent->getTable() . '.' . $this->parent->getPk(),
Db::raw('=' . $this->parent->getTable() . '.' . $this->parent->getPk()),
],
$this->morphType => $this->type,
])->fetchSql()->count();