数据库查询事件问题,是否应该获取监听最后一次结果才对,而不是数组
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Start at the shown select(BaseQuery) method and trace db->trigger('before_select', $query) to confirm whether it returns an array of listener results or the final result. Verify the fallback query path and define done as correctly using the final listener result when present, while preserving normal query execution when no listener handles the event.
Written by the indexing model from the issue text.
Description
$resultSet返回的是一个数组永远也进入不了if语句,应修改为只获取最后一次结果
/**
* 查找记录
* @access public
* @param BaseQuery $query 查询对象
* @return array
* @throws DbException
* @throws ModelNotFoundException
* @throws DataNotFoundException
*/
public function select(BaseQuery $query): array
{
$resultSet = $this->db->trigger('before_select', $query);
//$resultSet返回的是一个数组永远也进入不了if
//应修改为,只获取最后一次结果
$resultSet = $this->db->trigger('before_select', $query,true);
if (!$resultSet) {
// 执行查询操作
$resultSet = $this->query($query, function ($query) {
return $this->builder->select($query);
});
}
return $resultSet;
}
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
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.
More from top-think/think-orm
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
在php7.3及以上版本中,会出错 Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in top-think/think-orm
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getgrav/grav-plugin-api#45 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RSS-Bridge/rss-bridge#5098 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
phingofficial/phing#2025 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
silverstripe/developer-docs#911 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100