sqlsrv_querysqlsrv_query
04/11/2019
本文内容
准备并执行语句。Prepares and executes a statement.
语法Syntax
sqlsrv_query(resource $conn, string $tsql [, array $params [, array $options]])
参数Parameters
$conn:与已准备的语句相关联的连接资源。$conn: The connection resource associated with the prepared statement.
$tsql:对应于已准备的语句的 Transact-SQL 表达式。$tsql: The Transact-SQL expression that corresponds to the prepared statement.
$params [可选]:对应于参数化查询中参数的值的阵列 。$params [OPTIONAL]: An array of values that correspond to parameters in a parameterized query. 该阵列的每个元素可以是以下项之一:Each element of the array can be one of the following:
文字值。A literal value.
PHP 变量。A PHP variable.
具有以下结构的 阵列 :An array with the following structure:
array($value [, $direction [, $phpType [, $sqlType]]])
下表提供对阵列的每个元素的描述:The description for each element of the array is in the following table:
元素Element
说明Description
$value$value
参数值、PHP 变量或通过引用传递的 PHP 变量。A literal value, a PHP variable, or a PHP by-reference variable.
$direction[可选]$direction[OPTIONAL]
用于指示参数方向的以下 SQLSRV_PARAM__ 常量之一:SQLSRV_PARAM_IN、SQLSRV_PARAM_OUT、SQLSRV_PARAM_INOUT * 。One of the following **SQLSRV_PARAM**_ constants used to indicate the parameter direction: _* SQLSRV_PARAM_IN**, SQLSRV_PARAM_OUT, SQLSRV_PARAM_INOUT. 默认值为 SQLSRV_PARAM_IN 。The default value is SQLSRV_PARAM_IN.
$phpType[可选]$phpType[OPTIONAL]
*SQLSRV_PHPTYPE__ 常量,用于指定返回的值的 PHP 数据类型 * 。A *SQLSRV_PHPTYPE_* _ constant that specifies PHP data type of the returned value.
$sqlType*[可选]$sqlType*[OPTIONAL]
*SQLSRV_SQLTYPE__ 常量,用于指定输入值的 SQL Server 数据类型 * 。A *SQLSRV_SQLTYPE_* _ constant that specifies the SQL Server data type of the input value.