您好,欢迎访问一九零五行业门户网

如何在 PHP 5.1.6 使用真正的mysql预处理?

测试代码:
setattribute(pdo::attr_emulate_prepares, false); $st = $pdo->prepare(select * from account where username =? limit ?,?); $st->execute(array('buding',0,2)); $res = $st->fetchall(); var_dump($res);?>

当在 php 5.1.6 测试时,wireshark检测到发送的语句是:
select * from account where username ='23' limit '2'
当在 php 5.3 测试时,wireshark检测到发送的语句是:
select * from account where username =? limit ?
如何才能在php 5.1.6使用真的的mysql预处理呢?这是一个bug,还是我使用的方式不对?
回复内容: 测试代码:
setattribute(pdo::attr_emulate_prepares, false); $st = $pdo->prepare(select * from account where username =? limit ?,?); $st->execute(array('buding',0,2)); $res = $st->fetchall(); var_dump($res);?>

当在 php 5.1.6 测试时,wireshark检测到发送的语句是:
select * from account where username ='23' limit '2'
当在 php 5.3 测试时,wireshark检测到发送的语句是:
select * from account where username =? limit ?
如何才能在php 5.1.6使用真的的mysql预处理呢?这是一个bug,还是我使用的方式不对?
php5.3.6以前,参数绑定默认是使用php的预处理对参数转义。如果使用pdo,建议升级到5.3.6以后的版本,同时在dsn中指定编码。
其它类似信息

推荐信息