This article is a summary of the company's API interface backend!
1. Naming precautions:
Do not use confusing names, such as index, index01...
I like to use pinyin...
For example:
public function zhuce(Request $request)
2. Database file modification:
Go to database.php and remove the prefix of the data;
3. Get the requested value:
$data = input();$uid = $uid['uid']; //获取uid $tel = $data['tel']; //获取电话号码 $pwd = $data['password'];//获取输入的密码 $macaddress = $data['macaddress'];//获取mac地址
4. Operation database:
(1) Native operation:
$mi = Db::query("select password from users where uid= {$uid}");
(2) name query:
$users = Db::name('users')->where('uid','=', $uid)//条件->select();
5 .Return JSON array:
// 返回json数组 $aa = array('code' =>$code, 'msg' => array( 'users'=>$users),);
Output:
echo json_encode($aa,256);
256 is to prevent garbled characters;
The above is the detailed content of API background processing of tp5. For more information, please follow other related articles on the PHP Chinese website!