根据文档,对sqlsrv_query()的调用应如下所示:
mixed sqlsrv_query ( resource $conn , string $sql [, array $params [, array $options ]] )
但是,假设我想在没有参数的情况下进行简单的SELECT查询,但是我确实想传递一些选项吗?
此代码段似乎工作异常,
$dbh = blah...blah...
$query = 'SELECT * FROM myTable';
$options = array('Scrollable' => SQLSRV_CURSOR_CLIENT_BUFFERED);
$statement = sqlsrv_query($dbh, $query, array(), $options);
有时会从sqlsrv_error()返回此错误:
Array
(
[0] => Array
(
[0] => IMSSP
[SQLSTATE] => IMSSP
[1] => -14
[code] => -14
[2] => An invalid parameter was passed to sqlsrv_query.
[message] => An invalid parameter was passed to sqlsrv_query.
)
)
将选项传递给sqlsrv_query而不传递参数的正确方法是什么?
根据以下建议,我也尝试过$statement = sqlsrv_query($dbh, $query, null, $options);
,但结果相同。
谢谢!