The difference between TP5 and TP3

Source: Internet
Author: User
TP5 made a lot of changes, more flexible, not so bloated, added some exciting features, such as Php7,unittest, but many TP3 under the habit, in TP5 may have to change.

1 Changes in routing
Defining routes in TP3

Java code

' url_route_rules ' = = Array (//define routing rules

'/^password (\/) *$/' = '/admin/auth/password ',

),



So with Http://xx.com/password and Http://xx.com/Admin/Auth/password.
can access the same address Http://xx.com/Admin/Auth/password

And in the TP5 is not, see route.php 1251 Line

Java code

if (Isset (self:: $rules [' name '] [$name]) | | isset (self:: $rules [' name '] [$name 2])} {

throw new HttpException (404, ' Invalid request: '. Str_replace (' | ', $depr, $url));

}



If the configured URL is defined in the route, direct access is not allowed and an exception is thrown

Java code

' Password ' = [' Admin/auth/password ', [' method ' = ' get '],



Routing access with the configuration is normal, but does not jump to Admin/auth/password
Http://xxx/password

Http://xxx/admin/auth/password Access will error

Java code

[0] HttpException in route.php line 1252

Illegal request: Admin/auth/password

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

Check if the address is defined as a route

$name = Strtolower ($module. '/' . Loader::p arsename ($controller, 1). '/' . $action);

$name 2 = ";

if (Empty ($module) | | isset ($bind) && $module = = $bind) {

$name 2 = strtolower (Loader::p arsename ($controller, 1). '/' . $action);

}

if (Isset (self:: $rules [' name '] [$name]) | | isset (self:: $rules [' name '] [$name 2])} {

throw new HttpException (404, ' Invalid request: '. Str_replace (' | ', $depr, $url));

}

}

return [' type ' = ' module ', ' module ' = ' $route];

}



The 2 model Find,select method returns the model object, not the data. The raw data can be obtained with GetData (). It is recommended that the method defined in model uses DB () to query the data before exposing the method to the controller call.

3 if the model ()->save () is used in foreach, the new data must be added->isupdate (false) Otherwise, only the first one will be insert, and the others become update. This estimate is a bug.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.