Which built-in functions does thinkphp have for database operations?

Source: Internet
Author: User
844Model class getModelName () get the name of the current Model getTableName () get the name of the current Model data table switchModel (type, vars = array () dynamically switch Model table () set the data table field () of the current operation to set the data field wher 8.4.4 Model class getModelName () to query get the name of the current Model getTableName () get the name of the data table of the current Model switchModel (type, vars = array () dynamically switches the model table () to set the current operation's data table field () to set the data field to be queried where () to set the query or operation Condition data (data) set data object order (order) set sorting limit (limit) query limit page (page) query paging join (join) perform JOIN query having (having) perform having query group (group) perform group query lock (lock) query lock distinct (distinct) unique query count (field) records statistics sum (field) Total number query min (field) minimum query max (field) maximum value query avg (field) average value query _ initialize () model initialization method _ facade (data) to process the data stored in the database _ before_write (& data) the callback method before data writing includes adding and updating add (data = '', options = array () adding data _ before_insert (& data, options) callback method before data writing _ after_insert (data, options) callback method after data writing selectAdd (fields = '', table ='', options = array ()) add record save (data = '', options = array () in Select mode to update data to database _ before_update (& data, options) callback method before data update _ after_update (data, options) callback method after successful update delete (options = array () delete data _ after_delete (data, options) callback method after successful deletion select (options = array () query dataset _ after_select (& resultSet, options) the callback method findAll (options = array () after successful query ()) select method alias _ options_filter (& options) expression filter callback method find (options = array () query data _ after_find (& result, options) the callback method setField (field, value, condition = '') for successful query sets a field value of the record setInc (field, condition ='', step = 1) field value increase setDec (field, condition = '', step = 1) field value decrease getField (field, condition ='', sepa = '') obtain a field value create (data = '', type ='') to create a data object autoCheckToken (data) form token to verify query (SQL) execute native SQL query execute (SQL = '') execute native SQL operation startTrans () start transaction commit () commit transaction rollback () transaction rollback getError () get model error information getDbError () get Database error information getLastInsID () get last executed SQL statement getPk () get primary key name getDbFields () get Data Table field information regex (value, rule) use regular expression verification data setProperty (name, value) to set the model's attribute value version 2.1 new method: db (linkNum, config = '') switch the current database connection advanced model class AdvModel topN (count, options = array () to query the first N records that meet the conditions getN (position = 0, options = array ()) query N records that meet the condition. 0 indicates the first record.-1 indicates the last record. first (options = array () obtains the first record that meets the condition. last (options = array ()) returns the specified data type setLazyInc (field, condition = '', step = 1, lazyTime = 0) field value delay increase setLazyDec (field, condition = '', step = 1, lazyTime = 0) field value delay decrease addConnect (config, linkNum = NULL) increase database connection delConnect (linkNum) delete database connection closeConnect (linkNum) close database connection switchConnect (linkNum, name = '') switch database connection patchQuery (SQL = array ()) run the SQL statement getPartitionTableName (data = array () to obtain the name of the table shard.

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.