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

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.

范例

Example #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 />";
}
?>

参见

相关文章
php cubrid mysql 兼容性函数 return the number of rows affected by the last sql statementphp ibm db2 函数 returns the auto generated id of the last insert query that successfully executed on this connectionphp ibm db2 函数 returns the number of rows affected by an sql statementphp firebird/interbase 函数 return the number of rows that were affected by the previous queryphp informix 函数 returns the number of columns in the queryphp ingres 函数 get the number of fields returned by the last queryphp ingres 函数 get the number of rows affected or returned by a queryphp maxdb 函数 returns the auto generated id used in the last queryphp maxdb 函数 returns the total number of rows changed deleted or inserted by the last executed statementphp maxdb 函数 returns the number of warnings from the last query for the given linkphp msql 函数 returns number of affected rowsphp session pgsql 函数 returns number of errors and last error messagephp sqlite 函数 returns the number of rows in a buffered result setphp sqlsrv 函数 retrieves the number of rows in a result setphp sqlsrv 函数 returns the number of rows modified by the last insert update or delete query executedphp sybase 函数 gets number of affected rows in last queryphp yaz 函数 returns number of hits for last searchphp mysqli stmt returns the total number of rows changed deleted or inserted by the last executed statementphp mysqli returns the number of warnings from the last query for the given linkphp mysqlnduhconnection returns the number of warnings from the last query for the given link
关注编程学问公众号