Home > Article > PHP Framework > Detailed introduction to the TP6 data set
The tp6 framework requires the use of the mysql database, so you still need to know some knowledge about mysql. Today I will take you to learn about the data set. Friends who need it can take a look. In
thinkphp6
, what is returned after the database query is a data set, which is of type think\Collection
and operates in the same way as an array. It's almost the same, except that you need to use some provided methods to process the data set.
The picture below is the method he listed:
The most commonly used ones are toArray and isEmpty.
$select=Db::table('shop_goods')->whrer('id',1)->select(); if($select->isEmpty()){ echo '数据为空'; exit; } print_r($select); print_r($select->toArray()); }
Since this query has results, the output result is:
Related recommendations: The latest 10 thinkphp video tutorial
The above is the detailed content of Detailed introduction to the TP6 data set. For more information, please follow other related articles on the PHP Chinese website!