濮阳杆衣贸易有限公司

主頁 > 知識庫 > Laravel模糊查詢區(qū)分大小寫的實例

Laravel模糊查詢區(qū)分大小寫的實例

熱門標(biāo)簽:聊城電話外呼系統(tǒng)公司 辦理重慶400電話 銅川電話機器人價格 青白江地圖標(biāo)注 江蘇電商外呼系統(tǒng)運營商 德陽中江如何申請400開頭電話 AI電話機器人OEM貼牌 智能電話機器人好公司門薩維 沛縣400電話辦理

Laravel的ORM特殊操作!

舉個例子:我們數(shù)據(jù)庫設(shè)計的編碼方式如果是ci,也就是說大小寫不敏感的話,我們搜索的時候,搜索test,那么結(jié)果是Test,test,teST等等都出來,但是我們加上like binary的話,那么搜索出來的就是test,不管你的mysql數(shù)據(jù)庫是什么編碼排序規(guī)則。

#passthru: array:10 [▼ 
0 => “insert” 
1 => “insertGetId” 
2 => “getBindings” 
3 => “toSql” 
4 => “exists” 
5 => “count” 
6 => “min” 
7 => “max” 
8 => “avg” 
9 => “sum” 
] 
#operators: array:26 [▼ 
0 => “=” 
1 => “” 
2 => “>” 
3 => “=” 
4 => “>=” 
5 => “>” 
6 => “!=” 
7 => “l(fā)ike” 
8 => “l(fā)ike binary” 
9 => “not like” 
10 => “between” 
11 => “ilike” 
12 => “” 
13 => “|” 
14 => “^” 
15 => “” 
16 => “>>” 
17 => “rlike” 
18 => “regexp” 
19 => “not regexp” 
20 => “~” 
21 => “~*” 
22 => “!~” 
23 => “!~*” 
24 => “similar to” 
25 => “not similar to” 
]

參考文件位置:

D:\phpStudy\WWW\BCCAdminV1.0\vendor\laravel\framework\src\Illuminate\Database\Query\Builder.php
 protected $bindings = [
  'select' => [],
  'join' => [],
  'where' => [],
  'having' => [],
  'order' => [],
  'union' => [],
 ];
 protected $operators = [
  '=', '', '>', '=', '>=', '>', '!=',
  'like', 'like binary', 'not like', 'between', 'ilike',
  '', '|', '^', '', '>>',
  'rlike', 'regexp', 'not regexp',
  '~', '~*', '!~', '!~*', 'similar to',
  'not similar to',
 ];
public function index($customer_type = null) {
 $search = request('search');
 $perPage = request('perPage') ? request('perPage') : 10;
 $customer_type = $customer_type ? $customer_type : request('customer_type');
 $data = Customer::select(['id', 'email', 'user_name', 'nick_name', 'status', 'phone', 'create_time'])
  ->where('customer_type', '=', $customer_type)
  ->where(function ($query) use ($search) {
   if ($search) {
    $query->where('user_name', 'like binary', '%' . $search . '%')
     ->orWhere('nick_name', 'like binary', '%' . $search . '%')
     ->orWhere('phone', 'like binary', '%' . $search . '%')
     ->orWhere('email', 'like binary', '%' . $search . '%');
   }
  })
  ->orderBy('create_time', 'desc')
  ->paginate($perPage);
 //追加額外參數(shù),例如搜索條件
 $appendData = $data->appends(array(
  'search' => $search,
  'perPage' => $perPage,
 ));
 return view('admin/customer/customerList', compact('data'));
}

以上這篇Laravel模糊查詢區(qū)分大小寫的實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • 對laravel in 查詢的使用方法詳解
  • laravel多條件查詢方法(and,or嵌套查詢)

標(biāo)簽:南寧 迪慶 烏魯木齊 鷹潭 三亞 赤峰 山南 濟寧

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Laravel模糊查詢區(qū)分大小寫的實例》,本文關(guān)鍵詞  Laravel,模糊,查詢,區(qū)分,大小,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Laravel模糊查詢區(qū)分大小寫的實例》相關(guān)的同類信息!
  • 本頁收集關(guān)于Laravel模糊查詢區(qū)分大小寫的實例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    嘉荫县| 阿拉善盟| 玛多县| 青田县| 焦作市| 汉阴县| 巴南区| 达州市| 娱乐| 黄龙县| 禄丰县| 大姚县| 宝清县| 图片| 嵊泗县| 明溪县| 错那县| 克拉玛依市| 固镇县| 兴隆县| 弋阳县| 海盐县| 甘泉县| 平谷区| 诸暨市| 邹城市| 沅江市| 同心县| 古交市| 铁力市| 滦南县| 香港| 康保县| 扎鲁特旗| 诏安县| 静安区| 太湖县| 丹凤县| 呼玛县| 旅游| 邵阳市|