Looking at the tutorial, there is an activereocord example, but there are too few examples. I just want to explore a few more by myself. I want to ask, can this be written simply or more standardized?
Just search the data called Huang XX, and then put the Chinese score 1
<code> public function activereocord2() { $use = D('classone'); $id = $use->getByname('黄某某')['id']; $condition ['id'] = $id; $use->where($condition)->setInc('语文',1); $this->oneRow($id); } </code>
Looking at the tutorial, there is an activereocord example, but there are too few examples. I just want to explore a few more by myself. I want to ask, can this be written simply or more standardized?
Just search the data called Huang XX, and then put the Chinese score 1
<code> public function activereocord2() { $use = D('classone'); $id = $use->getByname('黄某某')['id']; $condition ['id'] = $id; $use->where($condition)->setInc('语文',1); $this->oneRow($id); } </code>
<code>$use = D('classone'); $use->where(array('name' => '黄某某'))->setInc('语文',1);</code>
Not reading the manual carefully
Isn’t it just a result set after get by name? Why do you need to check it again? . .
Get the ID through the name, and then use the ID field to modify the field...
Didn’t you go around in a circle...
Obviously it can be completed in one sentence, but it has to take so many detours. When writing this kind of database operation, first write down the SQL statement, and then consider using it in conjunction with the model syntax.