PHP PDO撇号 [英] PHP PDO apostrophe

查看:81
本文介绍了PHP PDO撇号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从php执行存储过程(FIREBIRD):

I have a problem to execute a Stored Procedure (FIREBIRD) from php:

$sqlSP="select record_created,record_updated from SP_IMPORT_CRM_SELECTIE (11, 'AC015612','".$tester."'..............

当$ tester包含此符号时,我有问题..

When $tester containts this symbol ' I have a problem..

我该如何解决?

推荐答案

本质上,您需要先对字符串进行转义,然后才能在查询中使用它.

Essentially, you need to escape the string before using it within a query.

做到这一点的最佳方法是使用PDO准备好的语句:

The best way to do this is through the use of PDO prepared statements:

$sqlSP="select record_created,record_updated from SP_IMPORT_CRM_SELECTIE (11, 'AC015612',:tester)";
$ps=$dbhandle->prepare($sqlSP);
$ps->bindParam(':tester',$tester,PDO::PARAM_STR);
$ps->execute();

(假设$dbhandle是您的PDO对象)

(assuming that $dbhandle is your PDO object)

这篇关于PHP PDO撇号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆