在thinkphp中,count方法是一個(gè)統(tǒng)計(jì)查詢方法,用于統(tǒng)計(jì)數(shù)據(jù)表或者數(shù)據(jù)記錄數(shù),返回的結(jié)果就是統(tǒng)計(jì)的字符數(shù),語(yǔ)法為“$model -> [where() -> ] count();”。
本文操作環(huán)境:Windows10系統(tǒng)、thinkphp5版、Dell G3電腦。
thinkphp中count的用法是什么
ThinkPHP中的統(tǒng)計(jì)查詢方法
在ThinkPHP中系統(tǒng)提供以下幾個(gè)查詢方法的使用,方便于在后期需要做統(tǒng)計(jì)的使用。
count() 表示查詢表中總的記錄數(shù)
立即學(xué)習(xí)“PHP免費(fèi)學(xué)習(xí)筆記(深入)”;
count方法
語(yǔ)法:
$model?->?[where()?->?]?count();
案例:查詢部門(mén)表中的總記錄數(shù)。
????//count方法 ????public?function?test(){ ????????//實(shí)例化模型 ????????$model?=?M('Dept'); ????????//count方法 ????????$result?=?$model?->?count(); ????????//打印 ????????dump($result); ? ????}
顯示結(jié)果:
返回值是字符的形式。
sql跟蹤信息中的結(jié)果:
數(shù)據(jù)庫(kù)中的信息:
推薦學(xué)習(xí):《PHP視頻教程》
? 版權(quán)聲明
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載。
THE END
喜歡就支持一下吧
相關(guān)推薦