我想用下面的代码中检索从我的MSSQL数据库的一些数据:PHP web服务与PDO
public function areaGetCities($json){
$request = json_decode($json);
$response = '';
$response->list = array();
if (!empty($request->language_id) &&
!empty($request->country_id) &&
!empty($request->postal_code)){
$this->db_stmt = new PDOStatement();
$this->db_stmt = $this->db->prepare('EXECUTE areaGetCities :language_id, :country_id, :postal_code');
$this->db_stmt->bindParam(':language_id', $request->language_id, PDO::PARAM_INT);
$this->db_stmt->bindParam(':country_id', $request->country_id, PDO::PARAM_INT);
$this->db_stmt->bindParam(':postal_code', $request->postal_code, PDO::PARAM_STR, 40);
$this->db_stmt->execute();
while ($obj = $this->db_stmt->fetchObject()){
$response->list[] = $obj;
unset($obj);
}
}
return json_encode($response);
}
如果我打印errorInfo中()我得到
试图绑定参数号0 。SQL Server最多支持2100个参数。 IMSSP -29
我的问题是,我不从我的数据库中的任何结果,我必须让(我跑了相同参数的过程,我也得到2结果)。
想法?
编辑:我编辑了我的代码。现在我得到:
[Microsoft] [SQL Server Native Client 11.0] [SQL Server]形式参数“@postal_code”>没有被声明为OUTPUT参数,而是在请求>输出中传递的实际参数。
CREATE PROCEDURE areaGetCities(@language_id TINYINT, @country_id INT, @postal_code VARCHAR(40))
你从哪里看到'@'用于为PDOStatement参数添加前缀?它是':'对于命名参数,'''对于基于索引的参数。 –
向我们展示您的存储过程。 – kba
该过程不返回任何内容。 –