PHP Velho Oeste 2024

mssql_field_seek

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

mssql_field_seekFixe la position du pointeur de champ MS SQL Server

Avertissement

Cette fonction a été SUPPRIMÉE à partir de PHP 7.0.0.

Description

mssql_field_seek ( resource $result , int $field_offset ) : bool

Modifie la valeur du pointeur de champ. Lors du prochain appel à mssql_fetch_field() qui ne précisera pas de numéro de champ, le champ fixé par mssql_field_seek() sera retourné.

Liste de paramètres

result

La ressource du résultats à évaluer. Ce résultat provient d'un appel à la fonction mssql_query().

field_offset

La position du champ, en commençant à 0.

Valeurs de retour

Cette fonction retourne TRUE en cas de succès ou FALSE si une erreur survient.

Exemples

Exemple #1 Exemple avec mssql_field_seek()

<?php
// Connexion à MSSQL et sélection de la base de données
mssql_connect('MANGO\SQLEXPRESS''sa''phpfi');
mssql_select_db('php');

// Requête de sélection sur MSSQL
$query mssql_query('SELECT * FROM [php].[dbo].[persons]');

// Construction d'une table HTML
echo '<h3>Table structure for \'persons\'</h3>';
echo 
'<table border="1">';

// Entête 
echo '<thead>';
echo 
'<tr>';
echo 
'<td>Nom du champ</td>';
echo 
'<td>Type de données</td>';
echo 
'<td>Taille maximale</td>';
echo 
'</tr>';
echo 
'</thead>';

// Affichage de toutes les données
echo '<tbody>';

for (
$i 0$i mssql_num_fields($query); ++$i) {
    
// Lecture du champ : notez le paramètre 
    // field_offset qui n'est pas configuré. Voyez l'appel
    // à mssql_field_seek ci-dessous
    
$field mssql_fetch_field($query);

    
// Affichage de la ligne
    
echo '<tr>';
    echo 
'<td>' $field->name '</td>';
    echo 
'<td>' strtoupper($field->type) . '</td>';
    echo 
'<td>' $field->max_length '</td>';
    echo 
'</tr>';

    
// Déplacement du pointeur interne, jusqu'à la prochaine ligne
    // dans le résultat
    
mssql_field_seek($query$i 1);
}

echo 
'</tbody>';
echo 
'</table>';

// Libération du résultat
mssql_free_result($query);
?>

Voir aussi

add a note add a note

User Contributed Notes 1 note

up
0
kevin_tom at hotmail dot com
19 years ago
Don't know this would help.
If you are using mssql to loop through a web page. Here is how to do it:
Suppose you want to select a few fields from t1 joining to t2

$numPerPage=10;
if(empty($offset))
  $offset=0;
if($next_x){
  $offset+=$numPerPage;
}
if($previous_x){
  $offset-=$numPerPage;
}

$qry_string = "SELECT DISTINCT TOP $numPerPage t1.field1, t1.field2 from t1 LEFT
JOIN t2 ON t2.field1=t1.field1
WHERE t2.another_field='specific_val'
AND t1.fields
NOT IN
(SELECT DISTINCT TOP $offset tmpT1.field1
FROM t1 AS tmpT1 LEFT
JOIN t2 ON t2.field1=tmpT1.field1
WHERE t2.another_field='specific_val'
)";

// then run the above $qry_string using the while loop
To Top