Differences between mysql_unbuffered_query and mysql_query

Source: Internet
Author: User

Differences between mysql_unbuffered_query and mysql_query

PHP mysql_data_seek () function

Definition and usage

The mysql_data_seek () function moves the internal result pointer.

Syntax

Mysql_data_seek (data, row)

Parameters

Description

Data

Required. Returns a result set of the resource type. This result set is obtained from the call of mysql_query.

Row

Required. The number of rows of the new result set pointer to be set. 0 indicates the first record.

Description

Mysql_data_seek () moves the row pointer inside the MySQL result specified by the data parameter to the specified row number.

Call mysql_fetch_row () to return the row.

Row starts from 0. The value range of row is from 0 to mysql_num_rows-1.

However, if the result set is empty (mysql_num_rows () = 0), moving the pointer to 0 fails and an E_WARNING error is returned. mysql_data_seek () returns false.

Return Value

If the call succeeds, true is returned. If the call fails, false is returned.

Tips and comments

Note: mysql_data_seek () can only be used with mysql_query (), but cannot be used with mysql_unbuffered_query ().

Example

$ Conn = mysql_connect ('localhost', 'root', 'root ');

Mysql_query ('set names gbk ');

Mysql_select_db ('pw8', $ conn );

$ SQL = "SELECT * FROM shop_district ";

// $ Result = mysql_unbuffered_query ($ SQL, $ conn );

$ Result = mysql_query ($ SQL, $ conn );

While ($ row = mysql_fetch_array ($ result, MYSQL_NUM )){

Printf ("ID: % s FID: % s Name: % s

", $ Row [0], $ row [1], $ row [2]);

}

Mysql_data_seek ($ result, 0 );

While ($ row = mysql_fetch_array ($ result, MYSQL_NUM )){

Printf ("ID: % s FID: % s Name: % s

", $ Row [0], $ row [1], $ row [2]);

}

 

Mysql_free_result ($ result );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.