Forum und email

mysqli_field_seek

result->field_seek

(No version information available, might be only in CVS)

result->field_seek — Move o ponteiro do resultado para um campo especificado

Descrição

Estilo de procedimento:

int mysqli_field_seek ( object $result , int $fieldnr )

Estilo orientado a objeto (method):

result
int field_seek ( int $fieldnr )

Define o cursor dos campo para o índice indicado. A próxima chamada a mysqli_fetch_field() irá retornar as informações da definição do campo com este índice.

Nota: Para mover para o início da linha, passe um índice de valor zero.

Valores de retorno

mysqli_field_seek() retorna o valor anterior para o cursor do campo.

Veja também

mysqli_fetch_field()

Exemplo

Example#1 Estilo orientado a objeto

<?php
$mysqli 
= new mysqli("localhost""my_user""my_password""world");

/* check connection */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

$query "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";

if (
$result $mysqli->query($query)) {

    
/* Get field information for 2nd column */
    
$result->field_seek(1);
    
$finfo $result->fetch_field();
 
    
printf("Name:     %s\n"$finfo->name);
    
printf("Table:    %s\n"$finfo->table);
    
printf("max. Len: %d\n"$finfo->max_length);
    
printf("Flags:    %d\n"$finfo->flags);
    
printf("Type:     %d\n\n"$finfo->type);
    
    
$result->close();
}

/* close connection */
$mysqli->close();
?>

Example#2 Estilo de procedimento

<?php
$link 
mysqli_connect("localhost""my_user""my_password""world");

/* check connection */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

$query "SELECT Name, SurfaceArea from Country ORDER BY Code LIMIT 5";

if (
$result mysqli_query($link$query)) {

    
/* Get field information for 2nd column */
    
mysqli_field_seek($result1);
    
$finfo mysqli_fetch_field($result);
 
    
printf("Name:     %s\n"$finfo->name);
    
printf("Table:    %s\n"$finfo->table);
    
printf("max. Len: %d\n"$finfo->max_length);
    
printf("Flags:    %d\n"$finfo->flags);
    
printf("Type:     %d\n\n"$finfo->type);

    
mysqli_free_result($result);
}

/* close connection */
mysqli_close($link);
?>

Os exemplos acima devem produzir a seguinte saída:

Name:     SurfaceArea
Table:    Country
max. Len: 10
Flags:    32769
Type:     4