CURD and ThinkPHPCURD operations in ThinkPHP

Source: Internet
Author: User

CURD and ThinkPHPCURD operations in ThinkPHP

<? Php // query multiple records, returns a two-dimensional array $ result = M ("admin")-> select (); $ result = M ("admin ") -> where ("id> 2")-> select (); $ result = M ("admin")-> where ("id> 2 ") -> order ("id desc")-> limit ("0, 5")-> field ("id, username, psssword")-> select (); $ result = M ("admin")-> where ("id> 2")-> group ("messageId")-> having ("messageId> 3 ") -> order ("id desc")-> limit ("0, 5")-> field ("id, username, psssword")-> select (); // query a record and return a one-dimensional array $ result = M ("admin ")-> Find (); $ result = M ("admin")-> where ("id = 2")-> find (); // put the data to be processed in the array data $ data = array ("username" => 'wang', "password" => "123456"); // Add a record, returns the number of affected rows $ updateRowNum = M ("admin")-> add ($ data); // deletes the record, and returns the number of affected rows $ updateRowNum = M ("admin ") -> where ("id = 2")-> delete (); // modify the data in the new array new_data $ new_data = array ("username" => 'wang _ new', "password" => "123456_new"); // modify the record, returned Number of affected rows $ updateRowNum = M ("admin")-> wher E ("id = 2")-> save ($ new_data); // execute the select statement (two-dimensional array is returned for all rows or rows) $ result = M () -> query ("select * from admin a, user u where. id = user. aid "); // execute insert, update, and delete statements, and return the affected rows $ updateRowNum = M ()-> execute (" insert/update/delete statement "); // calculate the number of queried rows (generally used for select statements) $ row = M ("admin")-> select ()-> count (); $ row = M ("admin ") -> where ("id> 3")-> select ()-> count ();?>

 

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.