#### **一.關聯統計**
#### ***1.***使用withCount()方法,可以統計主表關聯附表的個數,輸出用profile\_count;
$list = UserModel::withCount('profile')->all(\[1,2,3\]);
//值得注意的是,比如withCount('profile')這個表,然后會有一個默認變量,profile\_count,這個數據就是統計的數據,這個是默認的,當然,也可以自定義
foreach($list as $user){
echo $user->profile\_count;//默認變量數據
}
withCount(\['profile'=>'**ps**'\])->all(\[1,2,3\]);
這個ps就是自定義的統計變量了
#### ***2.***關聯統計的輸出采用"關聯方法名"\_count,這種結構輸出
#### ***3.***不單單支持Count,還有這些統計方法,
withMax(),withMin(),withSum(),withAvg()
#### ***4.***除了withhCount()不需要指定字段,其他的統計方法都需要指定字段
$list = UserModel::withSum('profile','status')->all(\[1,2,3\])