从code
中选择country_code
,其中country
='?U?n?i?t?e?d?按country
asc限制1的?K?i?n?g?d?o?m'顺序
public function location_test(){
$locations = DB::table('accesses')
->select('country' ,DB::raw('count(*) as count'))
->join('ip2c_cache', 'accesses.ip', '=', 'ip2c_cache.ip')
->where('showcase_id', 5613)->groupby('country')
->get();
$mapData = "";
$locationData = array();
foreach ($locations as $location) {
$code = DB::table('country_code')
->select('code')->where('country', $location->country)
->orderBy('country')
->first();
$mapData = $mapData . '"' . $code->id . '":"' . $location->count . '",';
}
return $mapData;
}
答案 0 :(得分:0)
当我更改数据库的排序规则时,问题已解决