php sqlsrv_query,sqlsrv_query

本文详细介绍了PHP中的sqlsrv_query函数,用于准备并执行SQL语句,包括参数化查询。示例展示了如何插入、更新和绑定数据到sql_variant类型的表中。
摘要由CSDN通过智能技术生成

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值