首先实体类Score.php
<?php
namespace app\index\model;
use think\Model;
class Score extends Model {
private $uuid;
private $user;
private $math;
private $chinese;
private $english;
private $create_time;
}
接着Search.php
<?php
namespace app\index\controller;
use app\index\model\Score;
use think\Db;
use think\db\Where;
class Search {
public function index() {
$score = new Score();
$score->uuid = 665544;
$score->user = '逆羽';
$score->math = 66;
$score->chinese = 88;
$score->english = 99;
$score->create_time = date('Y-m-d H:i:s');
$score->save();
$score->save([
'uuid' => 665534,
'user' => '狗头',
'math' => 66,
'chinese' => 88,
'english' => 99,
'create_time' => date('Y-m-d H:i:s')
]);
$score->saveAll([
[
'uuid' => 665534,
'user' => '狗头',
'math' => 66,
'chinese' => 88,
'english' => 99,
'create_time' => date('Y-m-d H:i:s')
],
[
'uuid' => 665534,
'user' => '狗头',
'math' => 66,
'chinese' => 88,
'english' => 99,
'create_time' => date('Y-m-d H:i:s')
]
]);
}
}