I have been writing websites for a year, mostly PC-side websites. Recently, I changed my company and have an APP business, which involves interface issues, so I found some information and wrote some project interfaces. Remember it, write it down, and read it later.
The APP interface itself is not difficult. It is just like writing an ordinary website. However, the value assigned to the HTML page in the controller becomes an interface that outputs json data. The following is the code:
public function jiekou(){//查询 $User = M('User'); $list = $User->select();//查询数据 $return['list'] = $list; echojson($return);//接口返回的json数据了 }
public function delall()//删除 { $User = M('User'); $map['id']=1; if ($User->where($map)->delete()) { $return['code'] = 200; $return['msg'] = '删除成功'; echojson($return); } else { $return['code'] = 400; $return['msg'] = '删除失败'; echojson($return); } }