略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: sqlsrv_rows_affected

2024-11-14

sqlsrv_rows_affected

(No version information available, might only be in Git)

sqlsrv_rows_affectedReturns the number of rows modified by the last INSERT, UPDATE, or DELETE query executed

说明

sqlsrv_rows_affected(resource $stmt): int|false

Returns the number of rows modified by the last INSERT, UPDATE, or DELETE query executed. For information about the number of rows returned by a SELECT query, see sqlsrv_num_rows().

参数

stmt

The executed statement resource for which the number of affected rows is returned.

返回值

Returns the number of rows affected by the last INSERT, UPDATE, or DELETE query. If no rows were affected, 0 is returned. If the number of affected rows cannot be determined, -1 is returned. If an error occurred, false is returned.

范例

示例 #1 sqlsrv_rows_affected() example

<?php
$serverName 
"serverName\sqlexpress";
$connectionInfo = array( "Database"=>"dbName""UID"=>"username""PWD"=>"password" );
$conn sqlsrv_connect$serverName$connectionInfo);
if( 
$conn === false ) {
     die( 
print_rsqlsrv_errors(), true));
}

$sql "UPDATE Table_1 SET data = ? WHERE id = ?";

$params = array("updated data"1);

$stmt sqlsrv_query$conn$sql$params);

$rows_affected sqlsrv_rows_affected$stmt);
if( 
$rows_affected === false) {
     die( 
print_rsqlsrv_errors(), true));
} elseif( 
$rows_affected == -1) {
      echo 
"No information available.<br />";
} else {
      echo 
$rows_affected." rows were updated.<br />";
}
?>

参见

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/function.sqlsrv-rows-affected.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3