Home > php教程 > php手册 > body text

ThinkPHP 之 自定义模型、连贯操作要点

WBOY
Release: 2016-06-13 10:56:45
Original
888 people have browsed it

我来总结一下学了什么~
获取数据主键的方法:$goods_model -> getPk();
实例化数据表两种方法 new Model() ; M()快捷方法 快捷方法只占用一次内存而第一种方法会每次增加一次内存存储量
query()获得查询结果 execute()获得影响行数
D()方法用来获取自定义模型,D()函数的执行顺序为首先查找自定义模型当文件名和类名符合规则后执行自定义模型,若有不符合则查找表名进行实例化,若没有符合表名则返回false

连贯操作
field()为显示范围,where()为取值条件:用数组或对象作为条件,limit()为取值个数,order(para desc)为排序,group()为按照字段分组自动排序,having()另一种取值条件,table(tbname)为跨越表取值,table(db.tbname)为跨越数据库进行取值,定义数组$cont['para']=array('like','%a%');进行生成数组条件控制sql,sum()求和,avg()平均数,count()求个数

 

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!