Home  >  Article  >  Backend Development  >  ThinkPHP's custom models and coherent operation points_PHP tutorial

ThinkPHP's custom models and coherent operation points_PHP tutorial

WBOY
WBOYOriginal
2016-07-14 10:10:26860browse

Let me summarize what I learned~
Method to obtain the primary key of data: $goods_model -> getPk();
There are two ways to instantiate a data table: new Model(); M() shortcut method. The shortcut method only occupies memory once, while the first method will increase the memory storage amount each time
query() gets the query results execute() gets the number of affected rows
The D() method is used to obtain a custom model. The execution order of the D() function is to first search for the custom model. When the file name and class name match the rules, the custom model is executed. If there is any inconsistency, the table name is searched for instantiation. If If there is no matching table name, return false

Continuous operation
field() is the display range, where() is the value condition: use array or object as the condition, limit() is the number of values, order(para desc) is sorting, group() is automatic sorting according to field grouping, having () Another value condition, table(tbname) is to obtain values ​​across tables, table(db.tbname) is to obtain values ​​across databases, define array $cont['para']=array('like','% a%'); Generate array conditional control sql, sum() to find the sum, avg() to find the average, and count() to find the number

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477475.htmlTechArticleLet me summarize what I learned~ Method of obtaining the primary key of data: $goods_model - getPk(); Instantiate data Table two methods new Model(); M() shortcut method shortcut method only takes up memory once...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn