thinkphp Auto-Complete function description

Source: Internet
Author: User

One sentence in the Handbook is key:

Auto-Completion is a method that thinkphp provides for automatic data processing and filtering, and data processing is done automatically when the Create method is used.

This statement indicates that the time for AutoComplete to occur is when create () builds data instead of add and save. The corresponding model inside the $_auto completion time (as shown below) is also the creation () when the data set, create () the second parameter is the completion time represented. When create () does not add parameters, the default time is 1, that is, when new data is added, when the second parameter is 2 o'clock, that is, when the first parameter is not needed, the first argument is empty, that is, create (", 2); but This function seems to be just to tell the author whether to add or update, not mandatory (at least not yet found that it has any substantive function), such as I want to update the data is automatically set the value of a field, but I create () do not pass parameters, and then $_ Auto completion time is set to Self::model_insert, then $model->field (' Specify updated field ')->where (' updated condition, note that save does not update the database if there is no update condition)-- Save (), so you can complete the update of this field, of course Create (", 2), $_auto set Self::model_update also line.

P.S. thinkphp the field after reading the database has all changed to lowercase, after reading the use of all the lowercase, but when the update is inserted in the case of the database

Time to complete (optional)

Set the time for auto-completion, including:

Set Description
Self::model_insert or 1 Processing when new data is added (default)
Self::model_update or 2 Processing when updating the data
Self::model_both or 3 All cases are handled

thinkphp Auto-Complete function description

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.