top-think / top-think/think-orm
think-orm 当mongodb存数组为[0]时报错
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
vendor/topthink/think-orm/src/db/builder/Mongo.php:113
} elseif (isset($val[0]) && 'exp' === $val[0]) {
$result[$item] = $val[1];
}
Db::name('test')->insert(['key'=> 1, 'data' => [0]]);
当data存为[0]时报错,原因 $val[0] 为整形0 等于 字符串 'exp'
echo 'exp' == 0; 为true ,应该用 ===
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
Open vendor/topthink/think-orm/src/db/builder/Mongo.php at line 113 and reproduce the failure with Db::name('test')->insert(['key' => 1, 'data' => [0]]). Check the condition handling the first array value; done means storing data as [0] completes without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100