Laravel查询-进行查询时,Laravel似乎在每个字母之间添加?/空格

时间:2018-11-15 13:20:06

标签: mysql laravel

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;
}

1 个答案:

答案 0 :(得分:0)

当我更改数据库的排序规则时,问题已解决