问题描述
我在ODBC的PDO语句上遇到问题.
I'm having an issue with the PDO statements for ODBC.
我正在Windows Server 2003和PHP 5.4.x中使用SQL SERVER 7
I'm using SQL SERVER 7 in Windows Server 2003 and PHP 5.4.x
例如:
我有一个查询:
(这不是实际的查询,但适用于示例)
(this is not the actual query but it serves right for the example)
$query = SELECT * FROM table WHERE number = :number OR number = :number
在我的PHP中,我有:
in my php i have:
$conn = new PDO($connectionString);
$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$statement = $conn->prepare($query);
$statement->bindParam(':number', $someNumber);
$statement->execute();
这会引发错误
COUNT field incorrect or syntax error
问题是,bindParam只绑定第一次出现的:number ...,并且试图再次绑定它也不起作用.
The thing is, bindParam is only binding the FIRST occurrence of :number ... AND trying to bind it again doesn't work either.
是否可以将多个具有相同名称的命名参数绑定在一起?
Is there a way to bind multiple named params with the same name?
我正在尝试不使用带有?的位置参数.代替
I'm trying not to use positional params using the ? instead
推荐答案
从理论上讲,您可以打开对准备好的语句的仿真.
Theoretical you could turn on emulation of prepared statements.
http://www.php.net/manual/en/pdo. prepare.php
这篇关于PHP PDO bindParam/bindValue多次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!