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