Query with special character

QuestionsQuery with special character
Cedric asked 7 years ago

Hello,
I can not make this query work in phpgrig.
The query works fine when it’s called in a MySQL tool like SQLyog
http://rextester.com/LOV64823
With phpgrid it always returns the error right syntax to use near ”\nf_nt4 …  I have tried several options but can’t make it work.
Do you have any tips to fix this?
Thanks,
Cedric

4 Answers
Abu Ghufran Staff answered 7 years ago

There seems to be some limitation in escaping function of library.
One way to solve it is by escaping \ character again: e.g.
$g->select_command = str_replace(‘\\’,’\\\\’,$g->select_command);
This will skip the error. However when it comes to rendering, grid will remove \ character again as it assumes it as escaped character. To fix display edit lib/inc/jqgrid_dist.php and remove these lines:
foreach($row as $k=>$r)
$row[$k] = stripslashes($row[$k]);

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Cedric answered 7 years ago

ok thanks for the tips. I will look in creating a view in Mysql to avoir editing your library.

Cedric answered 7 years ago

Hello Abu,
I am still stuck with this.
Can you hekp me in fixing the escape characters?
This does not work:
$g->select_command = str_replace(‘\\’,’\\\\’,$g->select_command);
nor this
$g->select_command = str_replace(‘\\’,’\\\\’,$sql);
 
Thanks,
Cedric
 

Abu Ghufran Staff answered 7 years ago

Here is working demo code:
https://gist.github.com/gridphp/59449c4a5cbcd3fb8ce555b4992f565b#file-cedric-slash-demo-L22
I’m also emailing you updated build.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Cedric replied 7 years ago

thank you Abu, it is working fine now.

Your Answer

18 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?