Tp5 API background processing-php Tutorial

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.