ThinkPHP3.2 basic knowledge (3) and thinkphp3.2 basic knowledge

Source: Internet
Author: User

ThinkPHP3.2 basic knowledge (3) and thinkphp3.2 basic knowledge
1. How can I enable the debugging mode and enable the debugging mode?

// Enable the debugging mode. We recommend that you enable the annotation of the deployment phase in the development phase or set it to falsedefine ('app _ debug', True );

 

Enable the debugging mode: this helps you detect and analyze hidden problems and solve problems in a timely manner.

2. How do I define an empty controller and an empty operation?

Empty operation:

<? Phpnamespace Home \ Controller; use Think \ Controller; class CityController extends Controller {public function _ empty ($ name ){
// Resolve all city operations to the city method $ this-> city ($ name );}
// Note that the city method itself is the protected method protected function city ($ name ){
// Process echo 'current City' related to $ name. $ name ;}

 

Empty controller:

<? Phpnamespace Home \ Controller; use Think \ Controller; class EmptyController extends Controller {public function index () {// determine the city to be executed based on the current Controller name $ cityName = CONTROLLER_NAME; $ this-> city ($ cityName);} // note that the city method itself is the protected method protected function city ($ name) {// processing echo 'current City' related to the $ name City '. $ name ;}}

 

3. How do I define the pre-and post-operations of controller parameters?

Pre-operation: _ before _ operation name post-operation: _ after _ operation name

Example:

<? Phpnamespace Home \ Controller; use Think \ Controller; class IndexController extends Controller {// pre-operation method public function _ before_index () {echo 'before <br/> ';} public function index () {echo 'index <br/> ';} // post-operation method public function _ after_index () {echo 'after <br/> ';}}

 

4. write out the automatic verification rules. Verify the password field (pwd) rules when you modify and add them, and check the rules whether they are empty or not. The rules are as follows: the password must contain uppercase/lowercase letters and numbers and contain at least six characters;
Protected $ _ validate = array ('Password', 'require ',' the password cannot be blank! '), Array ('Password','/^ [a-zA-Z0-9] {6} $/',' the password cannot be less than six characters! ', 0, 'regex', 3 ),)

 

What are the 5.3 query methods and 8 query methods?

Three query methods: String, array, and Object

Eight query methods: expression query, quick query, interval query, Combined Query, statistical query, subquery, SQL query, and dynamic query

6. write out the sample code for the compound query in the combined query;
$where['name']  = array('like', '%thinkphp%');$where['title']  = array('like','%thinkphp%');$where['_logic'] = 'or';$map['_complex'] = $where;$map['id']  = array('gt',1);

 

7. Write operations that can be repeatedly called in coherent operations;

Where is used to query or update the defined strings, arrays, and objects of conditions.

Join is used to support strings and arrays for join queries.

Union is used to support strings, arrays, and objects for the union query.

Scope is used to name the range string, array

Bind is used for data binding operation arrays or multiple parameters.

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.