top-think / top-think/think-orm

db before_select 事件的重大bug,无解不能执行下去

Open
#199 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
437
Forks
188
PR merge metrics
No merged PRs in 30d

Description

before_select事件返回的一定是数组,因为Event类的diaptch,没有加once参数,方法返回的一定是数组. 而执行事件使用的是
if (!$resultSet)
判断结果一定是false,导致真正的查询没有调用

`$resultSet = $this->db->trigger('before_select', $query);

    if (!$resultSet) {
        // 执行查询操作
        $resultSet = $this->pdoQuery($query, function ($query) {
            return $this->builder->select($query);
        });
    }`

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the before_select trigger shown in the issue and trace Event::dispatch, then follow the database query path through db->trigger and pdoQuery. Verify how the event result is represented and when the fallback query runs. Done means a before_select event that does not provide a usable result no longer prevents the real select query from executing.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.