Home  >  Article  >  Backend Development  >  thinkphp coherent operation example analysis, thinkphp example analysis_PHP tutorial

thinkphp coherent operation example analysis, thinkphp example analysis_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:13:21745browse

thinkphp coherent operation example analysis, thinkphp example analysis

This article analyzes the coherent operation usage of thinkphp with examples. Share it with everyone for your reference. The specific analysis is as follows:

1. Commonly used consecutive operations, which can be used consecutively but in no particular order. There must be methods select, update, delete, and find at the end

1.where: Help us set query conditions

2.order: Sort the results

Copy code The code is as follows:
$arr=$m->order('id desc')->select();// String method, the default is asc ascending order, add desc to change it to descending order
$arr=$m->order(array('id'=>'desc','sex'=>'asc'))->select(); //Array method

3.limit: limit results
Copy code The code is as follows:
limit(2,5)//Take out 5 items from item 2
limit('2,5')//string formal parameters
limit(10)//Equivalent to limit(0,10), the default is to start from 0

4.field: Set query field
Copy code The code is as follows:
field('username as name,id') //Pass characters and modify the field name
field(array('username'=>'name','id')//Pass array query and modify field name
field('id',true) //Get all fields except id

5.table:Table

6.group: Group

7.having: related to grouping

2. Supplement

alias is used to define an alias for the current data table string

page is used to query paging (will be converted to limit internally) strings and numbers

join* is used to support joins for queries, strings and arrays

union* for union support for queries strings, arrays and objects

distinct distinct support for queries boolean

lock Lock mechanism for database Boolean value

cache is used to query cache and supports multiple parameters (described in detail in the cache section later)

relation is used for related queries (requires related model extension support) string

validate is used for automatic data verification array

auto is used for data auto-complete array

filter is used for data filtering string

scope* is used for named scope strings and arrays

I hope this article will be helpful to everyone’s ThinkPHP framework programming.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/916066.htmlTechArticlethinkphp coherent operation example analysis, thinkphp example analysis This article analyzes the thinkphp coherent operation usage. Share it with everyone for your reference. The specific analysis is as follows: 1. Commonly used consecutive operations...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn