本文介绍了Zend 2:SQLSRV:未设置 $prepareParams的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下

->setPrepareParams(array $prepareParams) 

Zend\Db\Adapter\Driver\Sqlsrv\Statement.php?

具体来说,当我使用它时:

Specifically, when I used this:

$this->tableGateway->select(array("Personalnummer = $personalnumber"));

它奏效了.但是当我使用它时:

It worked. But when I used this:

$this->tableGateway->select(array("Personalnummer" => $personalnumber));

它没有用.

我试图调试这个,发现 params 没有用我的第二种方法设置.

I tried to debug this and found that the params were not being set with my second method.

推荐答案

在您的数据库配置中,您的连接驱动程序是什么?PHP 仅通过 PDO 支持参数化查询,而 Zend Framework 无法超越 PHP 的能力.因此,要使 array("Personalnummer" => $personalnumber) 工作,您需要将配置 driver 键设为 pdo_sqlsrv.听起来你有 'driver' =>'Sqlsrv' 代替.

In your database configuration, what is your connection driver? PHP supports parameterized queries only through PDO, and Zend Framework cannot go beyond what PHP is capable of. Therefore, to get array("Personalnummer" => $personalnumber) to work, you need to have configuration driver key be pdo_sqlsrv. Sounds like you have 'driver' => 'Sqlsrv' instead.

这篇关于Zend 2:SQLSRV:未设置 $prepareParams的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 10:26