Home  >  Article  >  PHP Framework  >  Detailed introduction to the TP6 data set

Detailed introduction to the TP6 data set

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-04-01 14:48:093142browse

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

Detailed introduction to the TP6 data set

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:

Detailed introduction to the TP6 data set

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:

Detailed introduction to the TP6 data set

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!

Statement:
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