1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use Overtrue\Pinyin\Pinyin;
- use think\Db;
- class Demo extends Api
- {
-
-
-
-
-
- protected $noNeedLogin = ['test', 'test1'];
-
- protected $noNeedRight = ['test2'];
-
- private function shouzimu($string)
- {
-
- $pinyin = new Pinyin();
- $pinyin_arr = $pinyin->convert($string);
- $shouzimu = '';
- if(!empty($pinyin_arr)){
- foreach($pinyin_arr as $key => $val){
- $shouzimu .= strtoupper(substr($val,0,1));
- }
- }
- return $shouzimu;
- }
-
- public function test1()
- {
- $list = Db::name('video')->select();
- foreach($list as $key => $video){
- $shouzimu = $this->shouzimu($video['title']);
- Db::name('video')->where('id',$video['id'])->update(['search_title'=>$shouzimu]);
- }
- }
-
- public function test2()
- {
- $this->success('返回成功', ['action' => 'test2']);
- }
-
- public function test3()
- {
- $this->success('返回成功', ['action' => 'test3']);
- }
- }
|