dsjuimtq920056 2019-02-01 09:26
浏览 66

Laravel将特殊字符存储为数据库中的\ u00e9 - >如何在数据库中搜索特殊字符?

I do not know why, but as soon as I save a post with Laravel Backpack, the data stored with a special character is transformed.

Héllo becomes H\u00e9llo

It is a problem. I checked my data mysql and everything seems ok (I use homestead).

'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci'

The customer today want a search feature. And obviously, it does not work with searches on special characters ...

Here is my code for the search:

 public function searchNav(Request $request)
  {
    $search = $request->get('search');

    $buildings = Building::where('title', 'LIKE', '%' . $search . '%')->orWhere('city', 'LIKE', '%' . $search . '%')->published()->get();
    $activity = Activity::where('title', 'LIKE', '%' . $search . '%')->orWhere('city', 'LIKE', '%' . $search . '%')->published()->get();

    // Create a new collection and merge elements
    $all = new Collection();
    $all = $all->merge($buildings);
    $all = $all->merge($circuit);
    $all = $all->sortByDesc('updated_at');
    $this->data['items'] = $all->all();

    return view('pages.search-nav-results', $this->data);
  }

How do I say to my request that if I search for a word that says "Héllo", it finds me the elements stored in my database H\u00e9llo?

Thanks for your help!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100