top-think / top-think/think-orm
There is no active transaction 错误出现的原因
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
下面这段代码不够严谨,希望能够处理一下

PDOConnection
public function transaction(callable $callback)
{
$this->startTrans();
try {
$result = null;
if (is_callable($callback)) {
$result = $callback($this);
}
$this->commit();
return $result;
} catch (\Exception | \Throwable $e) {
$this->rollback();
throw $e;
}
}
这里面的 $this->rollback(); 这个一旦抛错,实际的错误就看不到了,其实实际的错误是
SQLSTATE[HY000]: General error: 1364 Field 'accessName' doesn't have a default value
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
Locate the PDOConnection::transaction entry point and read how commit and rollback errors are handled. Reproduce the shown case where the accessName field lacks a default value; done means the original SQLSTATE error remains visible even if rollback also fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100