实体类
<?php
namespace app\index\Model;
use think\Model;
class Score extends Model {
protected $pk = 'uuid';
protected $table = 'tp_score';
private $user;
}
实现类
<?php
namespace app\index\controller;
use app\index\Model\Score;
class Update {
public function index() {
$score = Score::where('uuid', '13579')->find();
$score->user = '老黑';
$score->save();
<?php
namespace app\index\controller;
use app\index\Model\Score;
class Update {
public function index() {
$score = Score::where('uuid', '13579')->find();
$score->user = '老黑';
$score->save();
$score = Score::get('13579');
$score->user = '李白';
$score->save();
$score->force()->save();
$score = new Score();
$score->save(
[
'user' => '李白',
'math' => 0
],
[
'uuid' => '13579'
]
);
$score = new Score();
$score->saveAll([
[
'uuid'=>'13579',
'user'=>'李白',
'english'=>0
],
[
'uuid'=>'13813822',
'user'=>'李白',
'english'=>0
]
]);
Score::where('uuid', '13579')->update([
'user' => '黧黑',
'math' => 88
]);
Score::update([
'uuid' => '13579',
'user' => 'll',
'math' => 121
]);
$score = new Score();
$score->isUpdate(true)->save();
$score->isUpdate(false)->save();
}
} $score = Score::get('13579');
$score->user = '李白';
$score->save();
$score->force()->save();
$score = new Score();
$score->save(
[
'user' => '李白',
'math' => 0
],
[
'uuid' => '13579'
]
);
$score = new Score();
$score->saveAll([
[
'uuid'=>'13579',
'user'=>'李白',
'english'=>0
],
[
'uuid'=>'13813822',
'user'=>'李白',
'english'=>0
]
]);
Score::where('uuid', '13579')->update([
'user' => '黧黑',
'math' => 88
]);
Score::update([
'uuid' => '13579',
'user' => 'll',
'math' => 121
]);
$score = new Score();
$score->isUpdate(true)->save();
$score->isUpdate(false)->save();
}
}
|