Analysis of thinkphp coherent operations

不言
Release: 2023-04-01 16:44:02
Original
1677 people have browsed it

This article mainly introduces thinkphp coherent operation. It analyzes the specific usage and common method meaning of coherent operation in detail in the form of examples. It is a very practical skill. Friends who need it can refer to it

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 can be used consecutively but in no particular order. There must be methods to select, update, delete, and find

1.where: Help us Set query conditions

2.order: Sort the results

$arr=$m->order('id desc')->select();//字符串方法,默认是asc升序排列,加desc改为降序排列  
$arr=$m->order(array('id'=>'desc','sex'=>'asc'))->select(); //数组方法
Copy after login

3.limit: Limit the results

limit(2,5)//从第2条取出5条  
limit('2,5')//字条串形式参数  
limit(10)//等同于limit(0,10)默认是从0开始
Copy after login

4.field: Set the query field

field('username as name,id') //传字符,修改字段名  
field(array('username'=>'name','id')//传数组查询,修改字段名  
field('id',true) //获取除了id以外的所有字段
Copy after login

5.table: Table

6.group: Grouping

7.having: Related to grouping

2. Supplement

alias is used to give the current Data table definition alias string

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

join* is used to join the query to support strings and arrays

union* The union used for query supports strings, arrays and objects

distinct The distinct used for query supports Boolean value

lock Lock mechanism for database Boolean value

cache is used to query the 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 data automatic validation array

auto For data automatic completion array

filter For data filtering string

scope* For named range string, array

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Analysis of ThinkPHP custom configuration files

##

The above is the detailed content of Analysis of thinkphp coherent operations. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template