ThinkPHP limit () usage details, thinkphplimit. ThinkPHP limit () usage details, thinkphplimit This article introduces the use of ThinkPHP limit () method. The limit method can be used to obtain the number of entries in the specified range for database operation results. ThinkPHP limit () usage details, thinkphplimit
This article describes how to use the limit () method of ThinkPHP. The limit method can be used to obtain the number of entries in the specified range for database operation results. That is equivalent to the limit clause in the mysql Query statement.
The limit method is also one of the coherent operation methods of model classes. it is mainly used to specify the number of queries and operations, especially when querying by page. L of ThinkPHP
The imit method can be compatible with all database driver classes.
Usage 1. limit the number of results
For example, you can obtain 10 users that meet the requirements by calling the following code:
$User = M('User'); $User->where('status=1')->field('id,name')->limit(10)->select();
The limit method can also be used for write operations, such as updating three data entries that meet the requirements:
$User = M('User'); $User->where('score=100')->limit(3)->save(array('level'=>'A'));
Usage 2. paging query
It is a commonly used limit method for querying articles by page. for example:
$Article = M('Article'); $Article->limit('10,25')->select();
It indicates to query the article data. the 25 pieces of data starting from the first row of the article may also be affected by the where condition and limit sorting ).
After version 3.1, you can also use:
$Article = M('Article'); $Article->limit(10,25)->select();
For large data tables, use limit to limit query results. otherwise, large memory overhead and performance problems may occur.
The usage of limit () in ThinkPHP is described so much. I hope it will be helpful to you and thank you very much for your support for the help House website!
The usage of limit () is described in detail. thinkphplimit this article describes how to use the limit () method of ThinkPHP. The limit method can be used to obtain the number of results in a specified range for database operations ....