Simple ThinkPHP database access operations, thinkphp database access _ PHP Tutorial

Source: Internet
Author: User
Simple ThinkPHP database access operations, thinkphp database access. Simple operations for accessing ThinkPHP databases. comparing thinkphp database access to traditional SQL statements with the SQL statements in ThinkPHP, take the user table as an example $ userM (user); 1: SELECT * FROMuser ---------- $ u ThinkPHP database access simple operations, thinkphp database access

Comparing traditional SQL statements with SQL statements in ThinkPHP, the user table is used as an example.

     

$user=M('user');1: SELECT * FROM user----------$user->select();2: SELECT* FORM user WHERE id=2---------$user->find(2);3: SELECT username FORMuser-----$user->field('username')->select();
4: DELETE FORM username WHEREid=2------$user->delete(2);
5: UPDATE user SET username='newUsername' WHERE id=2-------$data['username']='newUsername' $user->save($data);
6: INSERT INTO user (name,password)VALUES('php','phpPwd')------$data['name']='php' $data['password']='phpPwd' $user->add($data);

Compare traditional SQL statements with SQL statements in ThinkPHP. take the user table as an example. $ user = M ('user'); 1: SELECT * FROM user ---------- $ u...

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.