Home  >  Article  >  Backend Development  >  The difference between tp5 and tp3

The difference between tp5 and tp3

巴扎黑
巴扎黑Original
2016-11-22 14:29:224360browse

TP5 has made great changes, it is more flexible, less bloated, and has added some exciting features, such as php7, unittest, etc. However, many habits developed under TP3 may need to be changed in TP5.

1 Routing changes defined in tp3

Java code

'URL_ROUTE_RULES' => array( //Define routing rules

        > '/Admin /Auth/password',

),


In this way, you can access the same address http://xx.com/password and http://xx.com/Admin/Auth/password
/xx.com/Admin/Auth/password

But it doesn’t work in tp5, see Route.php line 1251

Java code

if (isset(self::$rules['name'][$name ]) || isset(self::$rules['name'][$name2])) {

                                                                                                                                                                                                 ;

                                                                                                                                                         ['method'=>'get']],


It is normal to access with the configured route, but it will not jump to admin/auth/password
http://xxx/password

Use http: //xxx/admin/auth/password access will report an error

Java code

[0] HttpException in Route.php line 1252

Illegal request: admin/auth/password



$route = [$module, $controller, $action];

                                                                                                                                                                                                                    ​;

                               $name2 =                                                                                             $name2 = strtolower(Loader::parseName($controller, 1 ) . '/' . $action);

                                                             [$name2])) {

                                                                                                                                                                                                                                                                                        

                                                                                                                                                                                                                                    ; 'Module', 'module' = & gt; $ route];

}

2 model's Find, select and other methods returns the Model object, not data. You can use getData() to get the original data. It is recommended to define a method in the Model to query data using db(), and then expose the method to the controller for calls.

3 If you use Model()->save(); to add new data in foreach, you must add ->isUpdate(false). Otherwise, only the first one will be insert, and the others will become updates. This is probably a bug.

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