Azi*_*ima 5 php mysql collation laravel utf8mb4
case-insensitive我的表中有一个整理列。
col_name : hash_id, collation : utf8mb4_unicode_ci
Run Code Online (Sandbox Code Playgroud)
我得到结果yA2JeGs,并YA2JeGs当我搜索只是前者。
所以我需要更新排序规则以确保case-sensitivity该列。
我尝试更改该列的排序规则以创建一个新migration文件:
public function up()
{
Schema::table('product_match_unmatches', function (Blueprint $table) {
$table->string('hash_id')->collate('utf8mb4_bin')->change();
});
}
Run Code Online (Sandbox Code Playgroud)
还有 $table->string('hash_id')->collation('utf8mb4_bin')->change();
迁移成功运行,但排序规则保持不变。
我如何在 Laravel 中做到这一点?
您需要使用 laravel 架构构建器和下面提到的代码创建新的迁移并使列区分大小写:
$table->string('columName')->collation('utf8_bin')->change();
Run Code Online (Sandbox Code Playgroud)
https://laravel.com/docs/7.x/migrations
| 归档时间: |
|
| 查看次数: |
4776 次 |
| 最近记录: |