This article is a summary of the company's API interface background! 1. note: Do not use confusing names, such as index and index01... I like pinyin... for example: publicfunctionzhuce (Request $ request) 2. database file modification: Go to database. remove the data prefix in php; 3. get the request value: $ datainput (); $ uid This article summarizes the background of the company's API!
1. naming considerations:
Do not use confusing names, such as index, index01...
I like pinyin...
For example:
public function zhuce(Request $request)
2. database file modification:
Remove the data prefix from database. php;
3. get the request value:
$ Data = input (); $ uid = $ uid ['uid']; // Obtain uid $ tel = $ data ['tel']; // obtain the phone number $ pwd = $ data ['password']; // Obtain the entered password $ macaddress = $ data ['macaddress']; // Obtain the mac address
4. database operations:
(1) native operations:
$mi = Db::query("select password from users where uid= {$uid}");
(2) name query:
$ Users = Db: name ('users')-> where ('uid', '=', $ uid) // condition-> select ();
5. return a JSON Array:
// Return the json array $ aa = array ('code' => $ code, 'MSG '=> array ('users' => $ users ),);
Output:
echo json_encode($aa,256);
256 to prevent garbled characters;
-
-
-
The above is the details of API backend processing in tp5. For more information, see other related articles in the first PHP community!