From bf863a26de93030d8ef99154931c51718f1ed38f Mon Sep 17 00:00:00 2001 From: "yyh931018@qq.com" Date: Fri, 9 Sep 2022 10:58:01 +0800 Subject: [PATCH] update --- application/api/controller/Index.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/application/api/controller/Index.php b/application/api/controller/Index.php index 24c615e..19ba91e 100644 --- a/application/api/controller/Index.php +++ b/application/api/controller/Index.php @@ -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); + } + } }