thinkphp Framework Model coherent operation (eight)

Source: Internet
Author: User

Original: thinkphp framework model coherent operation (eight)

Thinkphp's consistent operation is also flexible:

* There may be some MySQL functions here are not all listed, we can extrapolate, the form of similar

I. Common and consistent operation

1.where
Help us set query criteria
2.order
Sort the results
$arr = $m->order (' id desc ')->select ();
$arr = $m->order (array (' id ' = ' desc ', ' sex ' = ' asc '))->select (); Sort multiple fields

Array form Query sort
$data [' id ']=array (2,3,4, ' or '); Check id=2 or id=3 or id=4
$arr = $user->where ($data)->order (' id desc ')->select ();
3.limit
Limit results
Limit (2,5)//starting from 2 strip 3
Or
Limit (' 2,5 ')
Limit (//limit) (0,10)
The method provided does not have a sequence of points, but in the end it must be select
$arr = $m->order (array (' id ' = ' desc ', ' sex ' = ' asc '))->limit ()->select ();
4.field
Set query fields
Field (' username as Name,id ')//Alias
Or
Field (Array (' username ' = ' name ', ' ID ')
Field (' id ', true)//Get all fields except ID
$arr = $m->order (' id ' = ' desc ')->limit (Ten)->field (' username as Name,id ')->select ();
5.table
6.group
7.having

thinkphp Framework Model coherent operation (eight)

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.