top-think / top-think/think-orm
Model::update()不返回是否操作成功,真的是蛋疼。
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 437
- Forks
- 188
- PR merge metrics
- No merged PRs in 30d
Description
实在想不通,返回$model本身的意义何在。链式操作吗,但我还真没用过这个链式操作。
Model::where($where)->update($date)->dowhat();?;
即使真有这种需求,赋值到一个变量就行了。
$model = new Model;
$model->where($where)->update($data);
$model->dowhat();
相反的,用模型更新的时候,为了知道操作是否成功,不得不写很多代码。
$model = new Model;
$res = $model->isUpdate(true, $where)->save($data);
再简便点,但总觉得有点怪怪的。
$res = (new Model)->isUpdate(true, $where)->save($data);
1.Model::where($where)->update($data)->dowhat();
2.$model = Model::where($where)->update($data);
$model->dowhat();
谁能举个栗子,讲一下什么情况会用到这两种用法?
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 with the Model::update() entry point in src/Model.php around line 880, then compare it with the isUpdate(true, $where)->save($data) usage shown in the issue. Determine and document the intended return value and the valid use cases for chaining or checking update success; the issue does not name tests to run.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100