Home > Article > Backend Development > ThinkPHP's custom models and coherent operation points_PHP tutorial
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