Laravel 查询生成器将 ' 替换为 '
Laravel Query builder replacing ' into '
我有 laravel 查询构建器查询 where is in the where condition 我有一个 ',
Select * from teams where name ilike ST. HELLEN'S
但是当我通过 Laravel 查询生成器 运行 这个查询时,它被转换成
Select * from teams where name ilike ST. HELLEN'S
最后我收到语法错误。任何人都知道如何解决这个问题?
我已经试过了
Select * from teams where name ilike ST. HELLEN\'S
Select * from teams where name ilike `ST. HELLEN'S`
这是我的代码:
$query = "Select * from teams where name ilike ST. HELLEN\'S";
$data = DB::select($query);
也尝试过:
DB::select(DB::raw($query));
有 3 种方法可以实现同样的效果
Way1: 使用另一个单引号:'ST. HELLEN''S'
方式2:在单引号前使用转义字符\
'
:'ST. HELLEN\'S'
方式三: 使用双引号代替单引号将字符串括起来:"ST. HELLEN'S"
我有 laravel 查询构建器查询 where is in the where condition 我有一个 ',
Select * from teams where name ilike ST. HELLEN'S
但是当我通过 Laravel 查询生成器 运行 这个查询时,它被转换成
Select * from teams where name ilike ST. HELLEN'S
最后我收到语法错误。任何人都知道如何解决这个问题?
我已经试过了
Select * from teams where name ilike ST. HELLEN\'S
Select * from teams where name ilike `ST. HELLEN'S`
这是我的代码:
$query = "Select * from teams where name ilike ST. HELLEN\'S";
$data = DB::select($query);
也尝试过:
DB::select(DB::raw($query));
有 3 种方法可以实现同样的效果
Way1: 使用另一个单引号:'ST. HELLEN''S'
方式2:在单引号前使用转义字符\
'
:'ST. HELLEN\'S'
方式三: 使用双引号代替单引号将字符串括起来:"ST. HELLEN'S"