Home  >  Article  >  Backend Development  >  What is the difference between TP5 and TP3.X

What is the difference between TP5 and TP3.X

黄舟
黄舟Original
2017-08-09 10:15:014163browse

The differences between TP5 and TP3. 3. The database query function of TP5 has been enhanced, and the original M function call can be replaced by the db function.

What is the difference between TP5 and TP3.X

Since TP5.0 is a brand new subversive and reconstructed version, many interviewers now like to ask about the difference between TP3.2 and TP5. Then What are the differences between them?

1. Directory

What is the difference between TP5 and TP3.X

What is the difference between TP5 and TP3.X

##TP5 Directory

What is the difference between TP5 and TP3.X

2. 3.X old ideas that need to be abandoned

URL Changes

First of all, I would like to apologize for the incorrect guidance that the laxity of 3. get' method to obtain 'id'. Strictly speaking, such URL does not belong to $_GET. It can now be obtained through 'param'. The specific use can be queried through the request part.

Model changes

The new version of the model query returns the default 'object', and the system adds the 'toArray' method by default. Many developers are 'all' or 'select' try to use 'toArray' to convert to an array. We hope developers can understand the concept of 'object', try to use 'object' for data use, or use the 'db' method for database operations. , and also remind some developers who abuse 'toArray', the result of 'all' or 'select' is an array collection of objects, which cannot be converted using 'toArray'.

3. Controller version comparison

tp3

What is the difference between TP5 and TP3.X

tp5

What is the difference between TP5 and TP3.X

TP3.2 controller name must end with Controller.class.php, while TP5 ends with .php;

TP3.2 controller template output uses $ this->display() method. In TP5, if the basic controller is inherited, use the $this->fetch() method. If it is not inherited, just use the view() assistant function;

Model

The database query function of 5.0 has been enhanced. The chain query that originally needed to be used through the model can be called directly through the Db class. The original M function call can be changed to the db function, for example:

3.2 version

M('User')->where(['name'=>'thinkphp'])->find();

5.0 version

db('User')->where('name','thinkphp')->find();

4. Assistant function

5.0Assistant function and3.2 The version of the single-letter function comparison is as follows:

For more related knowledge, please visit

PHP Chinese website! !

The above is the detailed content of What is the difference between TP5 and TP3.X. 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