Podręcznik PHP
Poprzedni |  | Następny

# mysqli_data_seek

(PHP 5 CVS only)

mysqli_data_seek

(no version information, might be only in CVS)

result->data_seek -- Adjusts the result pointer to an arbitary row in the result

## Description

Procedural style:

bool mysqli_data_seek ( object result, int offset)

Object oriented style (method):

class result {
bool data_seek ( int offset)
}

The mysqli_data_seek() function seeks to an arbitrary result pointer specified by the `offset` in the result set represented by `result`. The `offset` parameter must be between zero and the total number of rows minus one (0..mysqli_num_rows() - 1).

> Notatka: This function can only be used with unbuffered results attained from the use of the mysqli_store_result() or mysqli_query() functions.

## Return values

Zwraca `TRUE` w przypadku sukcesu, `FALSE` w przypadku porażki.

## Example

Przykład 1. Using the mysqli_data_seek function

`<?php
/* Open a connection */
$link = mysqli_connect("localhost", "username", "password");
mysqli_select_db("mydb");
/* Get some rows and store them */
$query = "SELECT DINSTINCT name FROM employee ORDER BY name";
$result = mysqli_query($query) or die(mysqli_error());
$rows = mysqli_store_result($result);
$total = mysqli_num_fields($rows);
if ($total > 0) { // there is at least one row
/* Get the last employee */
mysqli_data_seek($rows, mysqli_num_rows($result) -1);
$employee = mysqli_fetch_row($rows);
printf ("Employee name : %s\n", $employee[0]);
}
mysqli_free_result($rows);
mysqli_close($link);
?>`

## See also

mysqli_store_result(), mysqli_fetch_row(), mysqli_num_rows().

Poprzedni | Spis treści | Następny
mysqli_connect | Początek rozdziału | mysqli_debug