Thinkphp5.0 learning notes (2) and thinkphp5.0 learning notes
This article is a summary of the company's API interface Background!
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;
-
-
-
Tentative