略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: mssql_rows_affected

2024-12-23

mssql_rows_affected

(PHP 4 >= 4.0.4, PHP 5, PECL odbtp >= 1.1.1)

mssql_rows_affectedReturns the number of records affected by the query

Warning

This function was REMOVED in PHP 7.0.0.

Alternatives to this function include:

说明

mssql_rows_affected ( resource $link_identifier ) : int

Returns the number of records affected by the last write query.

参数

link_identifier

A MS SQL link identifier, returned by mssql_connect() or mssql_pconnect().

返回值

Returns the number of records affected by last operation.

范例

Example #1 mssql_rows_affected() example

<?php
// Delete all rows in a table
mssql_query('TRUNCATE TABLE [php].[dbo].[persons]');

echo 
'Deleted ' mssql_rows_affected($link) . ' row(s)';
?>
add a note add a note

User Contributed Notes 1 note

up
6
rowan dot collins at gmail dot com
12 years ago
Note that, as the page says, this function expects an MSSQL *Link* resource, not a *result* resource. This is a bit counter-intuitive, and differs from, for instance, pg_affected_rows (though not, apparently, mysql_affected_rows).

<?php
$link
= mssql_pconnect($db_host,$db_user,$db_pass);
mssql_select_db($db_name, $link);

$result = mssql_query('Select 1', $link);

$rows = mssql_rows_affected($result); # ERROR!
$rows = mssql_rows_affected($link); # Correct
?>

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

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