top-think / top-think/think-orm
可能是个bug belongsToMany 多对多 只能查出最后一条数据
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
例如在group模型下定义好 关联
public function user(): \think\model\relation\BelongsToMany
{
return $this->belongsToMany(User::class, GroupAccess::class)->orderRaw('CONVERT(name USING gbk)');
}
self::with('user')->select(). 关联数据只有最后一条被查询到
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Group model's belongsToMany(User::class, GroupAccess::class) relation, including orderRaw('CONVERT(name USING gbk)'), and the self::with('user')->select() query. Trace how the eager-loaded relation stores multiple users and verify that the completed behavior returns every related user rather than only the last one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100