ORM operations and associated models of ThinkPHP

Source: Internet
Author: User
After the object link ing M method is quick to instantiate the model, the object directly calls the field and assigns a value. you can directly call the add method to add a new value, and directly call the find method parameter to set the primary key value to obtain the data entry, you can directly call the select method parameter to obtain the number of entries that match the primary key value... "/> <scripttype =" text/javascript "src =" http: // www

Object link ing
After the M method quickly instantiates the model, the object directly calls the field and assigns a value. you can directly call the add method to add a new value. directly call the find method parameter to set the value of the primary key to obtain the data entry, you can directly call the select method parameter to obtain the data of each entry that matches the primary key value, you can directly call the find method parameter to set the primary key value, directly call its field to change the field value, and directly call the save method to update a piece of data, you can delete a data record by directly calling the delete method parameter as the primary key value.


!!!!!!!!! Tomorrow's task will be completed by adding, deleting, modifying, and querying goods with the dynamic record orm !!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


Verify

The data objects created by the create method are stored in the memory and are not actually written to the database. they are not actually written to the database until the add or save method is used. If the create method does not pass a value, the $ _ POST data is used by default. if the user submits the scalar content, the htl code that can be executed should be manually filtered. The htmlspecialchars method is available for illegal processing.
The data method is used to create data objects. It also supports the input of arrays and objects. data objects created using the data method are not automatically verified and filtered. It also automatically filters out invalid data types and non-existent strings.
Create () function workflow: obtain the data source, verify the validity of the data source, check the field ING, determine whether the submission status is added or edited, automatic data verification, form token verification, form data assignment, data is automatically generated to generate data objects;
Call a custom model and define protected $ _ validate = array () in the custom model. an array is the verification condition.
Array ('verification field name', 'verification rule', 'hprompt 'in array (). If condition 0 indicates that a field exists, verification is required, 2. verify if the data exists !!!!!!! You need to study it here !! It will only be tomorrow !!!!!!!!!, 'Additional condition', data execution status 1 is increased; 2 is updated; 3 is all; 3 is default) is a specific condition, specific field uniqueness length range not empty password format verification judgment same verification callback function verification


Automatic Completion
Also create a protection variable $ _ auto = array () on the custom model side ();
Similarly, there are specific arrays in the array ('fill field', 'fill rule', fill time 1 is increased 2 is updated 3 is all, 'Add rule function callback field string default ')


Both items will be verified during the execution of the create method!


In addition to assigning values to protection variables on the user-defined data model end, you can also create data rules in the activity section and call the setProperty method of the model object to assign data rules created before _ validate _ auto finally, execute the create method!

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.