简体   繁体   English

Yajra Datatables 单引号解析

[英]Yajra Datatables single quote parsing

I am using Yajra Datatable to create Apis in Laravel.我正在使用Yajra Datatable在 Laravel 中创建 Apis。

I have string called blog's where while fetching from database it gives me '我有一个名为 blog's where 的字符串,同时从数据库中获取它给了我' in response.作为回应。 I want to convert and return in proper apostrophe format only.我只想以正确的撇号格式转换和返回。

I tried following ways and both worked proper in php but I think it might be issue with Yajra Datatable.我尝试了以下方法,并且都在 php 中正常工作,但我认为这可能是 Yajra Datatable 的问题。

Can Someone help me out.有人可以帮我吗。

I've tried following ways and both worked fine in normal php.我尝试了以下方法,并且在正常 php 中都工作正常。

return mb_convert_encoding($data->blog_title, "UTF-8", "HTML-ENTITIES");

return str_replace("'","'",$data->blog_title);

Thanks谢谢

After a bit of R&D it was somewhere mentioned in Yajra Datatable documentation, written not clearly.经过一些研发后,它在 Yajra Datatable 文档中的某处提到了,但写得不是很清楚。 So if someone wants to escape the string and return it in original format, they have escape function.所以如果有人想转义字符串并以原始格式返回它,他们有转义 function。

This is how it can be used.这就是它的使用方式。

$list = Datatables::of($Blog)
                ->escapeColumns('blog_title')

It will return data with apostrope s.它将返回带撇号的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM