ThinkPHP3.2 basic Knowledge (III.)

Source: Internet
Author: User

1, how to open the debug mode, open debug mode What is the use?
// Open Debug mode suggest the development phase to open the deployment phase comment or set to False Define (' App_debug ',True);

The use of open Debug mode: To facilitate the timely detection of hidden problems and analysis, solve problems.

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

Empty operation:

<?phpnamespace Home\controller; UseThink\controller;classCitycontrollerextendscontroller{ Public function_empty ($name){
//to parse all the city's operations into the cities method $this->city ($name); }
//Note that the city method itself is the protected methodprotected functionCity$name){
//and $name, the city's related treatment. Echo' Current city '.$name; }

NULL Controller:

<?phpnamespace Home\controller; UseThink\controller;classEmptycontrollerextendscontroller{ Public functionindex () {//according to the current controller name to determine the operation of the city to perform         $cityName=Controller_name; $this->city ($cityName); }           //Note that the city method itself is the protected method     protected functionCity$name){               //and $name, the city's related treatment.         Echo' Current city '.$name; }}

3, how to define the pre-and post-operation parameters of the controller?

Pre-action: _before_ operation name: _after_ operation name

Example:

<?phpnamespace Home\controller; UseThink\controller;classIndexcontrollerextendscontroller{//pre-action method     Public function_before_index () {Echo' Before<br/> '; }         Public functionindex () {Echo' Index<br/> '; }      //Post-operation Method     Public function_after_index () {Echo' After<br/> '; }}

4. Please write out the rules of auto-authentication, require checking the Rules of password field (PWD) when modifying and adding, and checking whether or not it is empty, the rule is: the password should contain uppercase and lowercase letters and numbers and the length should be at least 6 bits;
protected $_validate=Array (' password ', ' Require ', ' password cannot be empty!       '),      array(' Password ', '/^[a-za-z0-9]{6}$/', ' password cannot be less than six bits! ', 0, ' regex ', 3),   )

What are the 5.3 query methods and 8 kinds of query method?

3 Ways to query: strings, arrays, objects

8 Query methods: Expression query, quick query, interval query, combinatorial query, statistical query, subquery, SQL query, dynamic query

6. Write a sample code for a composite query in a combination query;
$where [' Name ']  Array (' Like ', '%thinkphp% '); $where [' title ']  Array (' Like ', '%thinkphp% '); $where [' _logic '] = ' or '; $map $where ; $map [' ID ']  Array (' GT ', 1);

7. Please write the operation that can be repeated in the coherent operation;

Where the definition string, array, and object used to query or update conditions

Join support strings and arrays for queries

Union supports strings, arrays, and objects for the Union of Queries

Scope is used for naming range strings, arrays

Bind is used for data-bound manipulation arrays or multiple parameters

ThinkPHP3.2 basic Knowledge (III.)

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.