12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * Created by PhpStorm.
- * User: 97
- */
- namespace app\demo\controller;
- use app\BaseController;
- use app\common\business\Demo;
- class m extends BaseController{
- public function index(){
- $categoryId = $this->request->param("category_id",0,"intval");
- if(empty($categoryId)){
- return show(config("status.error"),"参数错误");
- }
- $demo = new Demo();
- $results = $demo->getDemoDataByCategoryId($categoryId);
- return show(config("status.success"),"ok",$results);
- //初学者 处理放在一个位置的方式
- // //use app\common\model\mysql\Demo;
- // //调取数据表对应的的 model ------ 在转移到 business 层
- // $model = new Demo();
- // $results = $model->getDemoDataByCategoryId($categoryId);
- //
- // if(empty($results)){
- // return show(config("status.error"),"数据为空");
- // }
- // $cagegorys = config("category");
- // foreach ($results as $key=>$result){
- // $results[$key]['categoryName'] = $cagegorys[$result['category_id']] ?? '--';
- // }
- // return show(config("status.success"),"ok",$results);
- }
- }
|