伍佰目录 短网址
  当前位置:海洋目录网 » 站长资讯 » 站长资讯 » 文章详细 订阅RssFeed

PHP - Manual: mssql_fetch_batch

来源:网络转载 浏览:39354次 时间:2023-11-14
mssql_fetch_field » « mssql_fetch_assoc
  • PHP 手册
  • 函数参考
  • 数据库扩展
  • 针对各数据库系统对应的扩展
  • Mssql
  • Mssql 函数

mssql_fetch_batch

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

mssql_fetch_batch — Returns the next batch of records

Warning

This function was REMOVED in PHP 7.0.0.

说明

mssql_fetch_batch ( resource $result ) : int

Returns the next batch of records.

参数

result

The result resource that is being evaluated. This result comes from a call to mssql_query().

返回值

Returns the number of rows in the returned batch.

范例

Example #1 mssql_fetch_batch() example

<?php
// Connect to MSSQL and select the database
$link = mssql_connect('MANGO\SQLEXPRESS', 'sa', 'phpfi');
mssql_select_db('php', $link);

// Send a query
$result = mssql_query('SELECT * FROM [php].[dbo].[people]', $link, 100);
$records = 10;

while ($records >= 0) {
    while ($row = mssql_fetch_assoc($result)) {
        // Do stuff ...
    }

    --$records;
}

if ($batchsize = mssql_fetch_batch($result)) {
    // $batchsize is the number of records left 
    // in the result, but not shown above
}
?>
add a note

User Contributed Notes 4 notes

up down 3 salvarez at jetmultimedia dot es5 years ago If you are doing more than one mssql_query(), you must do a mssql_free_result() to avoid undesirable results of mssql_fetch_batch() up down 0 jeffreznik6 years ago I was having issues doing two different select queries with batch sizes in the same connection.  The first one would run fine, the second one would always return one batch + 1 record (ie. batch size on the 2nd query was 250000 records, it would stop after 250001 and say it was complete even though there should have been 3m+ records).

I was able to overcome this by disconnecting from the DB (via mssql_close($conn);) and reconnecting before I ran the second query.  Now my second query returns all the records I need.

Though I would write this here as there is little to no documentation on this issue, and it may only be affecting me.  I am connecting from Linux (RHEL5) to SQL Server 2005 on the network, using FreeTDS.  If you have this same issue, try the above and it may work for you.
up down 0 doug dot pe at gmail dot com6 years ago This demonstrates the return value:
<?php
$connect = mssql_connect("databasename", "username", "password");
$sql = "SELECT * FROM huge_table";    //    returns 3271 rows, for example
$qry = mssql_query($SQL, $connect, 1000); // 1000 Rows batchsize
$batchsize = mssql_num_rows($qry);
print "$batchsize <br />\r\n";
do {
    $batchsize = mssql_fetch_batch($qry);
    print "$batchsize <br />\r\n";
} while ($batchsize);  // get the next batch until end
?>
returns:
1000
1000
1000
271
0
up down 0 brutalex4308 years ago This could be usefull if you have a large dataset:

<?php
$qry = mssql_query("SELECT * FROM huge_table", $conn, 1000); // 1000 Rows batchsize

    do {
      while ($row = mssql_fetch_row($qry)) {
          // do something like
          print_r($row);
      }
    } while (mssql_fetch_batch($navqry));  // get the next batch until end

?>
add a note

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

  推荐站点

  • At-lib分类目录At-lib分类目录

    At-lib网站分类目录汇集全国所有高质量网站,是中国权威的中文网站分类目录,给站长提供免费网址目录提交收录和推荐最新最全的优秀网站大全是名站导航之家

    www.at-lib.cn
  • 中国链接目录中国链接目录

    中国链接目录简称链接目录,是收录优秀网站和淘宝网店的网站分类目录,为您提供优质的网址导航服务,也是网店进行收录推广,站长免费推广网站、加快百度收录、增加友情链接和网站外链的平台。

    www.cnlink.org
  • 35目录网35目录网

    35目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向35目录推荐、提交优秀网站。

    www.35mulu.com
  • 就要爱网站目录就要爱网站目录

    就要爱网站目录,按主题和类别列出网站。所有提交的网站都经过人工审查,确保质量和无垃圾邮件的结果。

    www.912219.com
  • 伍佰目录伍佰目录

    伍佰网站目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向伍佰目录推荐、提交优秀网站。

    www.wbwb.net