Thinkphp coherent operation instance analysis, thinkphp instance analysis. Thinkphp coherent operation instance analysis, thinkphp instance Analysis This article analyzes thinkphp consistent operation usage. Share it with you for your reference. The specific analysis is as follows: 1. Analysis of commonly used thinkphp coherent operation instances and thinkphp instances
This article analyzes thinkphp's consistent operation usage. Share it with you for your reference. The specific analysis is as follows:
1. commonly used coherent operations can be used in succession, but there is no distinction between the front and back order. the following methods must be available: select, updata, delete, find
1. where: helps us set query conditions
2. order: sort the results
The code is as follows:
$ Arr = $ m-> order ('Id desc')-> select (); // string method. the default value is asc in ascending order. change desc to descending order.
$ Arr = $ m-> order (array ('id' => 'desc', 'sex' => 'asc ')-> select (); // array method
3. limit: limit the result
The code is as follows:
Limit (2nd) // extract 5 from
Limit ('2, 5') // string format parameter
Limit (10) // equivalent to limit (). The default value is from 0.
4. field: Set the query field
The code is as follows:
Field ('username as name, ID') // pass the character and modify the field name
Field (array ('username' => 'name', 'id') // transmits an array to query and modify the field name.
Field ('id', true) // Obtain all fields except id
5. table: table
6. group: group
7. having: related to groups
II. Supplement
Alias is used to define an alias string for the current data table.
Page is used to query the strings and numbers of pages (which are converted to limit internally ).
Join * supports strings and arrays for join queries.
Union * is used to support strings, arrays, and objects for the union query.
The distinct used for query supports boolean values.
Boolean value of the lock mechanism used by the database
The cache is used to query the cache. multiple parameters are supported (detailed descriptions will be made later in the cache section)
Relation is used for association query (support for extension of association model is required) string
Validate is used to automatically verify the array of data
Auto is used to automatically complete the array of data
Filter is used to filter strings.
Scope * is used to name the range string, array
I hope this article will help you with ThinkPHP framework programming.
In this article, we analyze thinkphp's consistent operation usage. Share it with you for your reference. The specific analysis is as follows: 1. common coherent operations...