就像這樣:
$res=Db::table("tb_employee")
//->where("id","<",20)
->field("black,count(*) as num")
//->order("id desc")
//->limit(3,5)
//->page(2,5)
->group("`black`")
->select();
$res=Db::table("tb_employee")
//->where("id","<",20)
->field("black,count(*) as num")
//->order("id desc")
//->limit(3,5)
//->page(2,5)
->group("`black`")
->select();
2018-11-19
我剛試了一下,select `group`,sum(num) as total from imooc_user group by `group`
這樣子也可以
這樣子也可以
2018-11-19
我用的是5.022版,db()方法第三個參數(shù)默認(rèn)是false,所以不需要再加了;以下是db()方法源碼:
function db($name = '', $config = [], $force = false)
{
return Db::connect($config, $force)->name($name);
}
function db($name = '', $config = [], $force = false)
{
return Db::connect($config, $force)->name($name);
}
2018-11-09