This commit is contained in:
yyh931018@qq.com
2022-09-09 10:58:01 +08:00
parent 69134db13f
commit bf863a26de

View File

@@ -20,4 +20,26 @@ class Index extends Api
{
$this->success('请求成功');
}
function GetRandStr($length){
//字符组合
$str = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$len = strlen($str)-1;
$randstr = '';
for ($i=0;$i<$length;$i++) {
$num=mt_rand(0,$len);
$randstr .= $str[$num];
}
return $randstr;
}
public function addStu()
{
$li = db('student')->find();
$array = array('identifier'=>rand(10000,99999),'nickname'=>$this->GetRandStr(8),'mobile'=>rand(10000000000,99999999999),'password'=>$this->GetRandStr(8),'avatar'=>'/uploads/20220908/b7c04fd15608f8b905d9808a401c9c02.jpg','gender'=>1,'birthday'=>'2022-08-08','age'=>10,'type'=>1,'disabled'=>0,'city'=>'哈尔滨','school'=>'xxx小学');
for ($i=1; $i<=50; $i++)
{
db('student')->insert($array);
}
}
}