说明
field方法属于模型的连贯操作方法之一,主要目的是标识要返回或者操作的字段,可以用于查询和写入操作
示例
Db::table(‘think_user‘)->field(‘id,title,content‘)->select();
段设置别名
Db::table(‘think_user‘)->field(‘id,nickname as name‘)->select();
使用函数
Db::table(‘think_user‘)->field(‘id,SUM(score)‘)->select();
Db::table(‘think_user‘)->field([‘id‘,‘title‘,‘content‘])->select();
Db::table(‘think_user‘)->field([‘id‘,‘nickname‘=>‘name‘])->select();
Db::table(‘think_user‘) ->field([‘id‘,‘concat(name,"-",id)‘=>‘truename‘,‘LEFT(title,7)‘=>‘sub_title‘]) ->select();
Db::table(‘think_user‘)->select(); Db::table(‘think_user‘)->field(‘*‘)->select(); Db::table(‘think_user‘)->field(true)->select();
Db::table(‘think_user‘)->field(‘content‘,true)->select(); Db::table(‘think_user‘)->field(‘user_id,content‘,true)->select(); Db::table(‘think_user‘)->field([‘user_id‘,‘content‘],true)->select();
本文出自 “素颜” 博客,请务必保留此出处http://suyanzhu.blog.51cto.com/8050189/1896484
原文地址:http://suyanzhu.blog.51cto.com/8050189/1896484