Home>Article>PHP Framework> What is the usage of count in thinkphp
In thinkphp, the count method is a statistical query method, used to count the number of data tables or data records. The returned result is the counted number of characters. The syntax is "$model -> [where() - > ] count();".
The operating environment of this article: Windows 10 system, ThinkPHP version 5, Dell G3 computer.
Statistical query methods in ThinkPHP
In ThinkPHP, the system provides the use of the following query methods, which is convenient for later needs Use of statistics.
count() represents the total number of records in the query table
count method
Syntax:
$model -> [where() -> ] count();
Case: Query the department table total.
//count方法 public function test(){ //实例化模型 $model = M('Dept'); //count方法 $result = $model -> count(); //打印 dump($result); }
Display results:
The return value is in the form of characters.
Results in sql tracking information:
Information in database:
Recommended learning : "PHP Video Tutorial"
The above is the detailed content of What is the usage of count in thinkphp. For more information, please follow other related articles on the PHP Chinese website!