Thinkphp5.0 learning notes (2) and thinkphp5.0 learning notes

Source: Internet
Author: User

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

 

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.